提交 d98d1280 编写于 作者: B Balaji Soundrarajan

Addressing PP Part 1

上级 d9df68b8
......@@ -2,7 +2,5 @@ artifacts/
infra/bin/
results/
temp/
DataBackup*/
consumptionTempResults.xml
*.json
*.csv
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#load "..\util\test_util.csx"
#load "..\util\runner_util.csx"
#load "..\util\tools_util.csx"
using System.IO;
......
......@@ -19,16 +19,7 @@ public class TraceManager
_cpcFullPath = Path.Combine(Environment.ExpandEnvironmentVariables(cpcFolderPath), "CPC.exe");
_scenarioGenerator = new ScenarioGenerator(Environment.ExpandEnvironmentVariables(scenarioPath));
}
public static void Run(string testExecutable, string argument)
{
var processResult = RunProcess(testExecutable, argument);
if (processResult.Failed)
{
throw new SystemException($@"The process {testExecutable} failed. {processResult.StdErr}");
}
}
public void Setup()
{
var processResult = RunProcess(_cpcFullPath, "/Setup /DisableArchive");
......@@ -103,11 +94,6 @@ public class TraceManager
_startEventAbsoluteInstance = 1;
_stopEventAbsoluteInstance = 1;
}
public void PrintTest()
{
Console.WriteLine("Test Printing by TraceManager");
}
public static ProcessResult RunProcess(string _cpcFullPath, string args)
{
......
......@@ -56,142 +56,4 @@ IEnumerable<string> GetAllCsxRecursive(string directoryName)
yield return fileName;
}
}
}
/// Takes a consumptionTempResults file and converts to csv file
/// Each info contains the <ScenarioName, Metric Key, Metric value>
bool ConvertConsumptionToCsv(string source, string destination, string requiredMetricKey)
{
Log("Entering ConvertConsumptionToCsv");
if (!File.Exists(source))
{
return false;
}
try
{
var result = new List<string>();
string currentScenarioName = null;
using (XmlReader xmlReader = XmlReader.Create(source))
{
while (xmlReader.Read())
{
if ((xmlReader.NodeType == XmlNodeType.Element))
{
if (xmlReader.Name.Equals("ScenarioResult"))
{
currentScenarioName = xmlReader.GetAttribute("Name");
// These are not test results
if (string.Equals(currentScenarioName, "..TestDiagnostics.."))
{
currentScenarioName = null;
}
}
else if (currentScenarioName != null && xmlReader.Name.Equals("CounterResult"))
{
var metricKey = xmlReader.GetAttribute("Name");
if (string.Equals(metricKey, requiredMetricKey))
{
var metricScale = xmlReader.GetAttribute("Units");
xmlReader.Read();
var metricvalue = xmlReader.Value;
result.Add($"{currentScenarioName}, {metricKey} ({metricScale}), {metricvalue}");
}
}
}
}
}
File.WriteAllLines(destination, result);
}
catch(System.Exception e)
{
System.Console.WriteLine(e.Message);
System.Console.WriteLine(e.StackTrace);
return false;
}
return true;
}
/// Gets a csv file with metrics and converts them to ViBench supported JSON file
string GetViBenchJsonFromCsv(string compilerTimeCsvFilePath, string execTimeCsvFilePath, string fileSizeCsvFilePath)
{
Log("Convert the csv to JSON using ViBench tool");
string branch = StdoutFrom("git", "rev-parse --abbrev-ref HEAD");
string date = FirstLine(StdoutFrom("git", $"show --format=\"%aI\" {branch} --"));
string hash = FirstLine(StdoutFrom("git", $"show --format=\"%h\" {branch} --"));
string longHash = FirstLine(StdoutFrom("git", $"show --format=\"%H\" {branch} --"));
string username = StdoutFrom("whoami");
string machineName = StdoutFrom("hostname");
string architecture = System.Environment.Is64BitOperatingSystem ? "x86-64" : "x86";
// File locations
string outJson = Path.Combine(GetCPCDirectoryPath(), $"Roslyn-{longHash}.json");
// ViBenchToJson does not like empty csv files.
string files = "";
if (compilerTimeCsvFilePath != null && new FileInfo(compilerTimeCsvFilePath).Length != 0) {
files += $@"compilertime:""{compilerTimeCsvFilePath}""";
}
if (execTimeCsvFilePath != null && new FileInfo(execTimeCsvFilePath).Length != 0) {
files += $@"exectime:""{execTimeCsvFilePath}""";
}
if (fileSizeCsvFilePath != null && new FileInfo(fileSizeCsvFilePath).Length != 0) {
files += $@"filesize:""{fileSizeCsvFilePath}""";
}
string arguments = $@"
{files}
jobName:""RoslynPerf-{hash}-{date}""
jobGroupName:""Roslyn-{branch}""
jobTypeName:""official""
buildInfoName:""{date}-{branch}-{hash}""
configName:""Default Configuration""
machinePoolName:""4-core-windows""
architectureName:""{architecture}""
manufacturerName:""unknown-manufacturer""
microarchName:""unknown-microarch""
userName:""{username}""
userAlias:""{username}""
osInfoName:""Windows""
machineName:""{machineName}""
buildNumber:""{date}-{hash}""
/json:""{outJson}""
";
arguments = arguments.Replace("\r\n", " ").Replace("\n", "");
ShellOutVital(@"\\mlangfs1\public\basoundr\vibenchcsv2json\ViBenchToJson.exe", arguments);
return outJson;
}
string FirstLine(string input) {
return input.Split(new[] {"\r\n", "\r", "\n"}, System.StringSplitOptions.None)[0];
}
void UploadTraces(string sourceFolderPath, string destinationFolderPath)
{
Log("Uploading traces");
if (Directory.Exists(sourceFolderPath))
{
// Get the latest written databackup
var directoryToUpload = new DirectoryInfo(sourceFolderPath).GetDirectories("DataBackup*").OrderByDescending(d=>d.LastWriteTimeUtc).FirstOrDefault();
if (directoryToUpload == null)
{
Log($"There are no trace directory starting with DataBackup in {sourceFolderPath}");
return;
}
var destination = Path.Combine(destinationFolderPath, directoryToUpload.Name);
CopyDirectory(directoryToUpload.FullName, destination);
}
else
{
Log($"sourceFolderPath: {sourceFolderPath} does not exist");
}
}
}
\ No newline at end of file
#load "test_util.csx"
using System.IO;
using System.Linq;
using System.Xml;
/// Takes a consumptionTempResults file and converts to csv file
/// Each info contains the <ScenarioName, Metric Key, Metric value>
bool ConvertConsumptionToCsv(string source, string destination, string requiredMetricKey)
{
Log("Entering ConvertConsumptionToCsv");
if (!File.Exists(source))
{
return false;
}
try
{
var result = new List<string>();
string currentScenarioName = null;
using (XmlReader xmlReader = XmlReader.Create(source))
{
while (xmlReader.Read())
{
if ((xmlReader.NodeType == XmlNodeType.Element))
{
if (xmlReader.Name.Equals("ScenarioResult"))
{
currentScenarioName = xmlReader.GetAttribute("Name");
// These are not test results
if (string.Equals(currentScenarioName, "..TestDiagnostics.."))
{
currentScenarioName = null;
}
}
else if (currentScenarioName != null && xmlReader.Name.Equals("CounterResult"))
{
var metricKey = xmlReader.GetAttribute("Name");
if (string.Equals(metricKey, requiredMetricKey))
{
var metricScale = xmlReader.GetAttribute("Units");
xmlReader.Read();
var metricvalue = xmlReader.Value;
result.Add($"{currentScenarioName}, {metricKey} ({metricScale}), {metricvalue}");
}
}
}
}
}
File.WriteAllLines(destination, result);
}
catch(System.Exception e)
{
System.Console.WriteLine(e.Message);
System.Console.WriteLine(e.StackTrace);
return false;
}
return true;
}
/// Gets a csv file with metrics and converts them to ViBench supported JSON file
string GetViBenchJsonFromCsv(string compilerTimeCsvFilePath, string execTimeCsvFilePath, string fileSizeCsvFilePath)
{
Log("Convert the csv to JSON using ViBench tool");
string branch = StdoutFrom("git", "rev-parse --abbrev-ref HEAD");
string date = FirstLine(StdoutFrom("git", $"show --format=\"%aI\" {branch} --"));
string hash = FirstLine(StdoutFrom("git", $"show --format=\"%h\" {branch} --"));
string longHash = FirstLine(StdoutFrom("git", $"show --format=\"%H\" {branch} --"));
string username = StdoutFrom("whoami");
string machineName = StdoutFrom("hostname");
string architecture = System.Environment.Is64BitOperatingSystem ? "x86-64" : "x86";
// File locations
string outJson = Path.Combine(GetCPCDirectoryPath(), $"Roslyn-{longHash}.json");
// ViBenchToJson does not like empty csv files.
string files = "";
if (compilerTimeCsvFilePath != null && new FileInfo(compilerTimeCsvFilePath).Length != 0) {
files += $@"compilertime:""{compilerTimeCsvFilePath}""";
}
if (execTimeCsvFilePath != null && new FileInfo(execTimeCsvFilePath).Length != 0) {
files += $@"exectime:""{execTimeCsvFilePath}""";
}
if (fileSizeCsvFilePath != null && new FileInfo(fileSizeCsvFilePath).Length != 0) {
files += $@"filesize:""{fileSizeCsvFilePath}""";
}
string arguments = $@"
{files}
jobName:""RoslynPerf-{hash}-{date}""
jobGroupName:""Roslyn-{branch}""
jobTypeName:""official""
buildInfoName:""{date}-{branch}-{hash}""
configName:""Default Configuration""
machinePoolName:""4-core-windows""
architectureName:""{architecture}""
manufacturerName:""unknown-manufacturer""
microarchName:""unknown-microarch""
userName:""{username}""
userAlias:""{username}""
osInfoName:""Windows""
machineName:""{machineName}""
buildNumber:""{date}-{hash}""
/json:""{outJson}""
";
arguments = arguments.Replace("\r\n", " ").Replace("\n", "");
ShellOutVital(@"\\mlangfs1\public\basoundr\vibenchcsv2json\ViBenchToJson.exe", arguments);
return outJson;
}
string FirstLine(string input) {
return input.Split(new[] {"\r\n", "\r", "\n"}, System.StringSplitOptions.None)[0];
}
void UploadTraces(string sourceFolderPath, string destinationFolderPath)
{
Log("Uploading traces");
if (Directory.Exists(sourceFolderPath))
{
// Get the latest written databackup
var directoryToUpload = new DirectoryInfo(sourceFolderPath).GetDirectories("DataBackup*").OrderByDescending(d=>d.LastWriteTimeUtc).FirstOrDefault();
if (directoryToUpload == null)
{
Log($"There are no trace directory starting with DataBackup in {sourceFolderPath}");
return;
}
var destination = Path.Combine(destinationFolderPath, directoryToUpload.Name);
CopyDirectory(directoryToUpload.FullName, destination);
}
else
{
Log($"sourceFolderPath: {sourceFolderPath} does not exist");
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册