private void Log(RunStats stats, string packageId) { if (_logger != null) { _logger.WriteLine(stats.ToCsv(packageId)); _logger.Flush(); } RunStats prevStats = null; if (_baselineStats != null) { if (!_baselineStats.TryGetValue(packageId, out prevStats)) { Console.WriteLine("Didn't find baseline package: {0}", packageId); } } if (_htmlLogger != null) { _jsonResults.AppendFormat(@"[ [{0}], [{1}] ], ", stats.ToCsv(packageId), prevStats == null ? "" : prevStats.ToCsv(packageId)); } stats.Write(prevStats); }
void Start() { chosenSide = -2; rotButtons = GameObject.Find("rotationButtons"); if (rotButtons != null) { rotButtons.SetActive(false); } forward = back = rotLeft = rotRight = false; menuPanel = GameObject.Find("PauseMenu"); if (menuPanel != null) { menuPanel.SetActive(true); RunStats.Reset(); menuPanel.SetActive(false); } if (GameObject.Find("ResumeTextBox") != null) { resumeText = GameObject.Find("ResumeTextBox").GetComponent <Text>(); if (resumeText != null) { resumeText.text = ""; } } }
private void button1_Click(object sender, EventArgs e) { DialogResult result = openFileDialog1.ShowDialog(); if (result == DialogResult.OK) { string file = openFileDialog1.FileName; //byte[] fileData = File.ReadAllBytes(file); //string fileString = Convert.ToBase64String(fileData); try { _sensorLog = _sensorService.GetSensorLog(file); GenerateChart(_sensorLog); chart1.Visible = true; chart1.ChartAreas[0].AxisY.ScaleView.ZoomReset(); chart1.ChartAreas[0].AxisX.ScaleView.ZoomReset(); RunStats stats = new RunStats(_sensorLog); label1.Text = stats.ToString(); } catch (IOException) { } } }
public ConsoleOutputRunListener() { _console = new DefaultConsole(); _timer = new RunStats(); _output = new ProgressOutput(_console); _summary = new FailedSpecificationsSummary(new VerboseOutput(_console), _console); }
private static int Main(string[] args) { List <string> packages = new List <string>(); if (args.Length == 0) { DisplayHelp(); return(0); } int? topCount = null, comboCount = null, runCount = null; bool combo = false; int? seed = null, dumpMembers = null; string packagePath = null, logPath = null, htmlLogPath = null, dirRun = null; DependencyType depType = DependencyType.Standard; bool installMissingPackages = false, installAll = false, cleanup = true, lowAnalysis = false, wait = false; Dictionary <string, RunStats> stats = null; foreach (var arg in args) { if (arg == "/?" || arg == "--help") { DisplayHelp(); return(0); } else if (arg == "/install_missing") { installMissingPackages = true; } else if (arg == "/install_all") { installAll = true; } else if (arg == "/low") { lowAnalysis = true; } else if (arg == "/no_cleanup") { cleanup = false; } else if (arg == "/wait") { wait = true; } else if (arg.StartsWith("/package_list:")) { string filename = arg.Substring("/package_list:".Length); try { packages.AddRange(File.ReadAllLines(filename)); } catch (Exception e) { Console.WriteLine("Failed to read package list: {0}", filename); Console.WriteLine(e.Message); return(-1); } } else if (arg.StartsWith("/package:")) { string packageName = arg.Substring("/package:".Length); if (String.IsNullOrWhiteSpace(packageName)) { Console.WriteLine("Missing package name"); return(-3); } foreach (var name in packageName.Split(',')) { packages.Add(name.Trim()); } } else if (arg.StartsWith("/dir:")) { dirRun = arg.Substring("/dir:".Length); if (String.IsNullOrWhiteSpace(dirRun)) { Console.WriteLine("/dir: missing directory name"); return(-3); } else if (!Directory.Exists(dirRun)) { Console.WriteLine("/dir: Directory does not exist"); return(-52); } cleanup = false; } else if (arg.StartsWith("/log:")) { logPath = arg.Substring("/log:".Length); if (String.IsNullOrWhiteSpace(logPath)) { Console.WriteLine("Missing log file name"); return(-16); } } else if (arg.StartsWith("/html:")) { htmlLogPath = arg.Substring("/html:".Length); if (String.IsNullOrWhiteSpace(htmlLogPath)) { Console.WriteLine("Missing HTML log file name"); return(-25); } } else if (arg.StartsWith("/package_path:")) { packagePath = arg.Substring("/package_path:".Length); if (String.IsNullOrWhiteSpace(packagePath)) { Console.WriteLine("Missing package path"); return(-10); } if (!Directory.Exists(packagePath)) { Console.WriteLine("Package path directory does not exist"); return(-11); } } else if (arg.StartsWith("/seed:")) { int seedInt; if (!Int32.TryParse(arg.Substring("/seed:".Length), out seedInt)) { Console.WriteLine("Bad seed value: {0}", arg.Substring("/seed:".Length)); return(-8); } seed = seedInt; } else if (arg.StartsWith("/combo:")) { string comboArgs = arg.Substring("/combo:".Length); if (String.IsNullOrWhiteSpace(comboArgs)) { Console.WriteLine("Missing combo values"); return(-4); } var comboArgsArray = comboArgs.Split(','); if (comboArgsArray.Length != 1 && comboArgsArray.Length != 2) { Console.WriteLine("Invalid number of arguments for combination run: {0}", comboArgs); return(-6); } int comboArgValue; if (!Int32.TryParse(comboArgsArray[0], out comboArgValue)) { Console.WriteLine("Invalid package count for combination run: {0}", comboArgsArray[0]); return(-5); } comboCount = comboArgValue; if (comboArgsArray.Length > 1) { if (!Int32.TryParse(comboArgsArray[1], out comboArgValue)) { Console.WriteLine("Invalid run count for combination run: {0}", comboArgsArray[1]); return(-7); } runCount = comboArgValue; } } else if (arg.StartsWith("/combo")) { combo = true; } else if (arg.StartsWith("/devdependencies")) { depType = DependencyType.Development; } else if (arg.StartsWith("/top:")) { int topCountInt; if (!Int32.TryParse(arg.Substring("/top:".Length), out topCountInt)) { Console.WriteLine("Bad top count: {0}", arg.Substring("/top:".Length)); return(-2); } topCount = topCountInt; } else if (arg.StartsWith("/dump_members:")) { int dumpMembersInt; if (!Int32.TryParse(arg.Substring("/dump_members:".Length), out dumpMembersInt)) { Console.WriteLine("Bad dump members count: {0}", arg.Substring("/dump_members:".Length)); return(-2); } dumpMembers = dumpMembersInt; } else if (arg.StartsWith("/dump_members")) { dumpMembers = 1; } else if (arg.StartsWith("/baseline:")) { stats = new Dictionary <string, RunStats>(); string baselinePath = arg.Substring("/baseline:".Length); if (String.IsNullOrWhiteSpace(baselinePath) || !File.Exists(baselinePath)) { Console.WriteLine("Bad baseline path: {0}", baselinePath); return(-20); } var baselineEntries = File.ReadAllLines(baselinePath).Skip(1).ToArray(); foreach (var line in baselineEntries) { var kvp = RunStats.Parse(line); if (kvp.Key != null) { stats.Add(kvp.Key, kvp.Value); } } } else { Console.WriteLine("Unknown option: {0}", arg); return(-15); } } if (packages.Count == 0) { Console.WriteLine("No packages were specified"); return(-9); } if (topCount != null) { packages = new List <string>(packages.Where((value, index) => index < topCount.Value)); } if (packagePath == null) { if (dirRun == null) { packagePath = CreateTempDirectoryPath(); Console.WriteLine("Packages cached at {0}", packagePath); installMissingPackages = true; } else { packagePath = dirRun; } } Random random; if (seed == null) { seed = Environment.TickCount; if (comboCount != null) { Console.WriteLine("Seed set to {0}", seed); } } random = new Random(seed.Value); TextWriter logger = null, htmlLogger = null; if (logPath != null) { logger = new StreamWriter(logPath); } if (htmlLogPath != null) { htmlLogger = new StreamWriter(htmlLogPath); } using (logger) using (htmlLogger) using (var driver = new AnalysisDriver( packages.ToArray(), packagePath, installMissingPackages, installAll, depType, cleanup, wait, random, logger, htmlLogger, dumpMembers, lowAnalysis, stats )) { if (combo) { comboCount = packages.Count; runCount = 1; } try { if (dirRun != null) { driver.RunDirectory( dirRun, Path.GetFileName(dirRun), packages.ToArray(), 1 ); } else if (comboCount == null) { driver.RunAll(); } else { for (int i = 0; i < (runCount ?? 1); i++) { driver.RunCombo(comboCount.Value, i + 1); } } } catch (AssertFailedException e) { Console.WriteLine("Run failed: {0}", e.Message); return(-100); } catch (Exception e) { Console.WriteLine("Error during run: {0}\r\n{1}", e.Message, e.StackTrace); return(-200); } } for (int i = 0; i < 3; i++) { GC.Collect(2); GC.WaitForPendingFinalizers(); } //AnalysisValue.DumpStats(); //VariableDef.DumpStats(); return(0); }
public void Write(RunStats baseline = null) { Console.ForegroundColor = ConsoleColor.Gray; int left = Console.CursorLeft; const string timeFormat = "{0,6} ms ", fileFormat = "{0,4} files ", parserWorkingSetFormat = "{0,4} MB parser WS, ", parserGcFormat = "{0,4} MB parser GC Mem, ", workingSetFormat = "{0,4} MB WS, ", gcFormat = "{0,4} MB GC Mem, ", totalCompletionFormat = "{0,3} ", secondLevelCompletionFormat = "({0,5}) completions"; string format = timeFormat + fileFormat.Replace("{0", "{1") + parserWorkingSetFormat.Replace("{0", "{6") + parserGcFormat.Replace("{0", "{7") + workingSetFormat.Replace("{0", "{2") + gcFormat.Replace("{0", "{5") + totalCompletionFormat.Replace("{0", "{3") + secondLevelCompletionFormat.Replace("{0", "{4"); Console.WriteLine(format, Time, FileCount, TotalWorkingSet, TotalCompletions, SecondLevelCompletions, GcMem, ParserTotalWorkingSet, ParserGcMem ); if (baseline != null) { Console.CursorLeft = Math.Max(1, left - "BASE: ".Length); Console.Write("BASE: "); Console.WriteLine(format, baseline.Time, baseline.FileCount, baseline.TotalWorkingSet, baseline.TotalCompletions, baseline.SecondLevelCompletions, baseline.GcMem, baseline.ParserTotalWorkingSet, baseline.ParserGcMem ); Console.CursorLeft = Math.Max(1, left - "DIFF: ".Length); Console.Write("DIFF: "); LogDiff(timeFormat, Time - baseline.Time); LogDiff(fileFormat, FileCount - baseline.FileCount); LogDiff(parserWorkingSetFormat, ParserTotalWorkingSet - baseline.ParserTotalWorkingSet); LogDiff(parserGcFormat, ParserGcMem - baseline.ParserGcMem); LogDiff(workingSetFormat, TotalWorkingSet - baseline.TotalWorkingSet); LogDiff(gcFormat, GcMem - baseline.GcMem); LogDiff(totalCompletionFormat, TotalCompletions - baseline.TotalCompletions, reversed: true); LogDiff(secondLevelCompletionFormat, SecondLevelCompletions - baseline.SecondLevelCompletions, reversed: true); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Gray; } }
public void RunDirectory(string testDir, string packageId, string[] packages, int runOrder) { Stopwatch sw = new Stopwatch(); for (int i = 0; i < 3; i++) { GC.Collect(GC.MaxGeneration); GC.WaitForPendingFinalizers(); } var startingGcMem = GC.GetTotalMemory(true); var workingSet = Process.GetCurrentProcess().WorkingSet64; var startTime = sw.ElapsedMilliseconds; long parserGcMem = 0; long parserWorkingSet = 0; sw.Start(); var analyzer = Analysis.Analyze( testDir, _lowAnalysis ? AnalysisLimits.MakeLowAnalysisLimits() : null, () => { for (int i = 0; i < 3; i++) { GC.Collect(GC.MaxGeneration); GC.WaitForPendingFinalizers(); } parserGcMem = GC.GetTotalMemory(true); parserWorkingSet = Process.GetCurrentProcess().WorkingSet64; } ); sw.Stop(); var endingGcMem = GC.GetTotalMemory(true); var endWorkingSet = Process.GetCurrentProcess().WorkingSet64; int completionCount = 0, secondLevelCompletionCount = 0; foreach (var module in analyzer.AllModules) { if (String.Equals(Path.Combine(testDir, "app.js"), module.FilePath, StringComparison.OrdinalIgnoreCase) || String.Equals(Path.Combine(testDir, "index.js"), module.FilePath, StringComparison.OrdinalIgnoreCase) || String.Equals(Path.Combine(testDir, "server.js"), module.FilePath, StringComparison.OrdinalIgnoreCase)) { foreach (var package in packages) { string packageName = package.Split('@')[0]; string requireCode = String.Format("require('{0}')", packageName); var moduleMembers = module.Analysis.GetMembersByIndex(requireCode, 0); completionCount += moduleMembers.Count(); foreach (var moduleMember in moduleMembers) { var memberCode = requireCode + "." + moduleMember.Completion; secondLevelCompletionCount += module.Analysis.GetMembersByIndex(memberCode, 0).Count(); } if (_dumpMembers != null) { DumpMembers(module.Analysis, requireCode, 0); } } break; } } var time = sw.ElapsedMilliseconds - startTime; int fileCount = analyzer.AllModules.Count(); var totalWorkingSet = (endWorkingSet - workingSet) / (1024 * 1024); var parserTotalWorkingSet = (parserWorkingSet - workingSet) / (1024 * 1024); var stats = new RunStats( completionCount, secondLevelCompletionCount, time, fileCount, parserTotalWorkingSet, (parserGcMem - startingGcMem) / (1024 * 1024), totalWorkingSet, (endingGcMem - startingGcMem) / (1024 * 1024), runOrder ); Log(stats, packageId); if (_wait) { Console.ReadLine(); } GC.KeepAlive(analyzer); #if DEBUG //Console.WriteLine(analyzer.GetAnalysisStats()); #endif if (_cleanup) { Directory.Delete(testDir, true); } else { Console.WriteLine(" Ran in {0}", testDir); } }
public void Write(RunStats baseline = null) { Console.ForegroundColor = ConsoleColor.Gray; int left = Console.CursorLeft; const string timeFormat = "{0,6} ms ", fileFormat = "{0,4} files ", parserWorkingSetFormat = "{0,4} MB parser WS, ", parserGcFormat = "{0,4} MB parser GC Mem, ", workingSetFormat = "{0,4} MB WS, ", gcFormat = "{0,4} MB GC Mem, ", totalCompletionFormat = "{0,3} ", secondLevelCompletionFormat = "({0,5}) completions"; string format = timeFormat + fileFormat.Replace("{0", "{1") + parserWorkingSetFormat.Replace("{0", "{6") + parserGcFormat.Replace("{0", "{7") + workingSetFormat.Replace("{0", "{2") + gcFormat.Replace("{0", "{5") + totalCompletionFormat.Replace("{0", "{3") + secondLevelCompletionFormat.Replace("{0", "{4"); Console.WriteLine(format, Time, FileCount, TotalWorkingSet, TotalCompletions, SecondLevelCompletions, GcMem, ParserTotalWorkingSet, ParserGcMem ); if (baseline != null) { Console.CursorLeft = Math.Max(1, left - "BASE: ".Length); Console.Write("BASE: "); Console.WriteLine(format, baseline.Time, baseline.FileCount, baseline.TotalWorkingSet, baseline.TotalCompletions, baseline.SecondLevelCompletions, baseline.GcMem, baseline.ParserTotalWorkingSet, baseline.ParserGcMem ); Console.CursorLeft = Math.Max(1, left - "DIFF: ".Length); Console.Write("DIFF: "); LogDiff(timeFormat, Time - baseline.Time); LogDiff(fileFormat, FileCount - baseline.FileCount); LogDiff(parserWorkingSetFormat, ParserTotalWorkingSet - baseline.ParserTotalWorkingSet); LogDiff(parserGcFormat, ParserGcMem - baseline.ParserGcMem); LogDiff(workingSetFormat, TotalWorkingSet - baseline.TotalWorkingSet); LogDiff(gcFormat, GcMem - baseline.GcMem); LogDiff(totalCompletionFormat, TotalCompletions - baseline.TotalCompletions, reversed: true); LogDiff(secondLevelCompletionFormat, SecondLevelCompletions - baseline.SecondLevelCompletions, reversed: true); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Gray; } }
private void Log(RunStats stats, string packageId) { if (_logger != null) { _logger.WriteLine(stats.ToCsv(packageId)); _logger.Flush(); } RunStats prevStats = null; if (_baselineStats != null) { if (!_baselineStats.TryGetValue(packageId, out prevStats)) { Console.WriteLine("Didn't find baseline package: {0}", packageId); } } if (_htmlLogger != null) { _jsonResults.AppendFormat(@"[ [{0}], [{1}] ], ", stats.ToCsv(packageId), prevStats == null ? "" : prevStats.ToCsv(packageId)); } stats.Write(prevStats); }
public void RunDirectory(string testDir, string packageId, string[] packages, int runOrder) { Stopwatch sw = new Stopwatch(); for (int i = 0; i < 3; i++) { GC.Collect(GC.MaxGeneration); GC.WaitForPendingFinalizers(); } var startingGcMem = GC.GetTotalMemory(true); var workingSet = Process.GetCurrentProcess().WorkingSet64; var startTime = sw.ElapsedMilliseconds; long parserGcMem = 0; long parserWorkingSet = 0; sw.Start(); var analyzer = Analysis.Analyze( testDir, _lowAnalysis ? AnalysisLimits.LowAnalysisLimit : null, () => { for (int i = 0; i < 3; i++) { GC.Collect(GC.MaxGeneration); GC.WaitForPendingFinalizers(); } parserGcMem = GC.GetTotalMemory(true); parserWorkingSet = Process.GetCurrentProcess().WorkingSet64; } ); sw.Stop(); var endingGcMem = GC.GetTotalMemory(true); var endWorkingSet = Process.GetCurrentProcess().WorkingSet64; int completionCount = 0, secondLevelCompletionCount = 0; foreach (var module in analyzer.AllModules) { if (String.Equals(Path.Combine(testDir, "app.js"), module.FilePath, StringComparison.OrdinalIgnoreCase) || String.Equals(Path.Combine(testDir, "index.js"), module.FilePath, StringComparison.OrdinalIgnoreCase) || String.Equals(Path.Combine(testDir, "server.js"), module.FilePath, StringComparison.OrdinalIgnoreCase)) { foreach (var package in packages) { string packageName = package.Split('@')[0]; string requireCode = String.Format("require('{0}')", packageName); var moduleMembers = module.Analysis.GetMembersByIndex(requireCode, 0); completionCount += moduleMembers.Count(); foreach (var moduleMember in moduleMembers) { var memberCode = requireCode + "." + moduleMember.Completion; secondLevelCompletionCount += module.Analysis.GetMembersByIndex(memberCode, 0).Count(); } if (_dumpMembers != null) { DumpMembers(module.Analysis, requireCode, 0); } } break; } } var time = sw.ElapsedMilliseconds - startTime; int fileCount = analyzer.AllModules.Count(); var totalWorkingSet = (endWorkingSet - workingSet) / (1024 * 1024); var parserTotalWorkingSet = (parserWorkingSet - workingSet) / (1024 * 1024); var stats = new RunStats( completionCount, secondLevelCompletionCount, time, fileCount, parserTotalWorkingSet, (parserGcMem - startingGcMem) / ( 1024 * 1024), totalWorkingSet, (endingGcMem - startingGcMem) / (1024 * 1024), runOrder ); Log(stats, packageId); if (_wait) { Console.ReadLine(); } GC.KeepAlive(analyzer); #if DEBUG //Console.WriteLine(analyzer.GetAnalysisStats()); #endif if (_cleanup) { Directory.Delete(testDir, true); } else { Console.WriteLine(" Ran in {0}", testDir); } }
public static void ResetCurrent() { Current = new RunStats(); }
private void Awake() { _hud = GameObject.FindWithTag("HUD").GetComponent <Hud>(); RunStats.ResetCurrent(); }