private void RunCallback(PerformanceResult model) { if (InvokeRequired) { Invoke(new Action <PerformanceResult>(RunCallback), model); return; } dgvResults.DataSource = model.Result; DataGridViewHelper.MakeSortable(dgvResults); DataGridViewHelper.AutoSizeGrid(dgvResults); dgvResults.Sort(dgvResults.Columns[EventPerformanceConst.DurationTS], ListSortDirection.Descending); dgvResults.Columns[EventPerformanceConst.DurationTS].HeaderCell.SortGlyphDirection = SortOrder.Descending; dgvResults.ReadOnly = true; if (_lastSelectedEventId != -1) { dgvResults.ClearSelection(); foreach (DataGridViewRow row in dgvResults.Rows) { if (row.Cells[EventPerformanceConst.EventId].Value.ToString().Equals(_lastSelectedEventId.ToString())) { row.Selected = true; dgvResults.CurrentCell = row.Cells[0]; break; } } } lblTotalDuration.Text = $"Total Duration: {model.TotalDuration.ToReadableString()}"; lblTotalEvents.Text = $"Total Events: {model.TotalEvents}"; btnEditEvent.Enabled = true; StatusPanel.StatusUpdate(StatusModel.Completed); }
private (float, float, float) GetPercentageOfResult(PerformanceResult result) { float[] arr = { result.MillisecondsA, result.MillisecondsB, result.MillisecondsC }; float max = arr.Max(); return(result.MillisecondsA / max, result.MillisecondsB / max, result.MillisecondsC / max); }
private void WriteCase(StringBuilder sb, string testCase, string category, string categoryColor, PerformanceResult[] results, Func<PerformanceResult, double> valueGetter, Func<double, string> formatter) { sb.Append("<tr>"); WriteCell(sb, testCase); WriteCell(sb, category, categoryColor); double[] values = results.Where(c => c.Failure == null).Select(valueGetter).ToArray(); double max = values.DefaultIfEmpty().Max(); double min = values.DefaultIfEmpty().Min(); foreach (PerformanceResult result in results) { string color = GetColor(valueGetter, result, min); string text = result.Failure == null ? formatter(valueGetter(result)) : "error"; WriteCell(sb, text, color); string textPercent = result.Failure == null ? GetPercent(valueGetter(result), max) : "error"; WriteCell(sb, textPercent, color); } sb.Append("</tr>"); }
private void PrintReport() { try { DataTable dtData; string reportName = "PerformanceReport"; dtData = PerformanceResult.ToTable().Copy(); //dtData.Rows.Clear(); DataSet dsReport = new DataSet(); //dsReport.DataSetName = "DSREPORTDATA"; dtData.TableName = "REPORTDATA"; dsReport.Tables.Add(dtData); //dsReport.WriteXml("E:\\" + dsReport.DataSetName + ".xml", XmlWriteMode.WriteSchema); Dictionary <string, string> dictFormulas = new Dictionary <string, string>(); dictFormulas.Add("lblColumn0", HEADER[0]); dictFormulas.Add("lblColumn1", HEADER[1]); dictFormulas.Add("lblColumn2", HEADER[2]); dictFormulas.Add("lblColumn3", HEADER[3]); dictFormulas.Add("lblColumn4", HEADER[4]); dictFormulas.Add("lblColumn5", HEADER[5]); dictFormulas.Add("lblHeader", _reportTitle); reportName = (_perfOption == performanceOption.DocumentReleased || _perfOption == performanceOption.SampleSubmitted ? "PerformanceReport1" : "PerformanceReport"); frmReportViewer reportViewer = new frmReportViewer(dsReport, reportName, CrystalDecisions.Shared.ExportFormatType.NoFormat, dictFormulas); if (!reportViewer.ReadyToShowReport) { return; } reportViewer.ShowDialog(); } catch (Exception ex) { throw ex.LogException(); } }
static PerformanceResult RunTestForGraph(WorldGraph graph) { var result = new PerformanceResult(); Stopwatch sw = new Stopwatch(); result.name = graph.name; sw.Start(); graph.ProcessOnce(); sw.Stop(); result.processOnceTime = sw.Elapsed.TotalMilliseconds; sw.Reset(); sw.Start(); graph.Process(); sw.Stop(); result.processTime = sw.Elapsed.TotalMilliseconds; result.nodeProcessTime = new NodeProcessTime[graph.allNodes.Count()]; for (int i = 0; i < result.nodeProcessTime.Length; i++) { var node = graph.allNodes.ElementAt(i); result.nodeProcessTime[i] = new NodeProcessTime(node.name, node.processTime); } result.totalAllocatedMemory = Profiler.GetTotalAllocatedMemoryLong(); result.totalReservedMemory = Profiler.GetTotalReservedMemoryLong(); result.totalUnusedReservedMemory = Profiler.GetTotalUnusedReservedMemoryLong(); return(result); }
private void WriteCase(StringBuilder sb, string testCase, PerformanceResult[] results) { WriteCase(sb, testCase, "Data size", results, c => FormatSize(c.Size)); WriteCase(sb, testCase, "Serialization time", results, c => FormatTimeSpan(c.SerializeTime.Total)); WriteCase(sb, testCase, "Deserialization time", results, c => FormatTimeSpan(c.DeserializeTime.Total)); WriteCase(sb, testCase, "Total time", results, c => FormatTimeSpan(c.SerializeTime.Total + c.DeserializeTime.Total)); }
public IPerformanceResult GetPerformanceResult(int session) { PerformanceResult performanceResult = new PerformanceResult(); _dataMaintainer.GetPerformanceResult(_globalInfo.RuntimeHash, session, performanceResult); return(performanceResult); }
/// <summary> /// Adds a log to be written to the database. Can be called concurrently. /// </summary> /// <param name="log"></param> public void Write(PerformanceResult log) { // Add the log to the queue _logs.Enqueue(log); // Start the batch writing process if not started already lock (writeLock) { if (_isWriting) { return; } _isWriting = true; } // Initialize the task to be executed in parallel var writingTask = new Task(WriteASingleBatch); writingTask.ContinueWith((t) => { lock (writeLock) { _isWriting = false; } }); writingTask.Start(); }
private void WriteCase(StringBuilder sb, string testCase, PerformanceResult[] results) { WriteCase(sb, testCase, "Data size", "Beige", results, c => c.Size, FormatSize); WriteCase(sb, testCase, "Serialization time", "Coral", results, c => c.SerializeTime.Total, FormatTimeSpan); WriteCase(sb, testCase, "Deserialization time", "LightSeaGreen", results, c => c.DeserializeTime.Total, FormatTimeSpan); WriteCase(sb, testCase, "Total time", "RoyalBlue", results, c => c.SerializeTime.Total + c.DeserializeTime.Total, FormatTimeSpan); }
private static string GetColor(Func<PerformanceResult, double> valueGetter, PerformanceResult result, double min) { string color = null; if (result.Failure != null) color = "red"; else if (Equals(valueGetter(result), min)) color = "DarkSeaGreen"; return color; }
/// <summary> /// Runs the process. /// </summary> /// <param name="context">Dummy / not in use</param> public void Run(object context) { // Prepare directory (clear previous results) if (Directory.Exists(ResultsDir)) { Directory.Delete(ResultsDir, true); Thread.Sleep(50); } Directory.CreateDirectory(ResultsDir); Thread.Sleep(50); // Start statistics file using (StreamWriter sw = new StreamWriter(Path.Combine(ResultsDir, StatisticsFile), false)) sw.WriteLine( "Instance" + ExportationConstants.CSV_DELIMITER + "Runtime" + ExportationConstants.CSV_DELIMITER + "SpaceUtil" + ExportationConstants.CSV_DELIMITER + "PackedPieces"); // Prepare Method.Config.TimeLimit = TimeSpan.FromSeconds(Timeout); Method.Config.Log = LogAction; // Execute all Instance instance = InstanceCreator(); while (instance != null) { // Quit, if desired if (_quit) { break; } // Prepare individual run Method.Instance = instance; Method.Reset(); instance.WriteXMLWithoutSolutions(Path.Combine(ResultsDir, instance.Name + "_raw.xinst")); // Execute StartSingleSolveAction?.Invoke(); PerformanceResult result = Method.Run(); FinishSingleSolveAction?.Invoke(); // Write result instance.WriteXML(Path.Combine(ResultsDir, instance.Name + "_sol.xinst")); using (StreamWriter sw = new StreamWriter(Path.Combine(ResultsDir, StatisticsFile), true)) sw.WriteLine( instance.Name + ExportationConstants.CSV_DELIMITER + result.SolutionTime.TotalSeconds.ToString(CultureInfo.InvariantCulture) + ExportationConstants.CSV_DELIMITER + instance.Solutions.Single().VolumeContainedRelative.ToString(CultureInfo.InvariantCulture) + ExportationConstants.CSV_DELIMITER + instance.Solutions.Single().NumberOfPiecesPacked.ToString(CultureInfo.InvariantCulture)); // Update view SubmitSolutionAction?.Invoke(instance.Solutions.Single(), Method.HasSolution, ResultsDir, instance.Name); // Create next instance instance = InstanceCreator(); } // Mark finish FinishAction?.Invoke(); }
private DummyPerformanceStopwatch() { m_Result = new PerformanceResult() { Counter = 0, Global = true, Instances = 0, Name = "::dummy::", Type = PerformanceCounterType.TimeMilliseconds }; }
private int GenerateNewTestNumber(Entities ctx, PerformanceResult performanceResult) { var testResults = ctx.PartIResult .Where(r => r.DataBaseType == (int)dataBaseType && r.TestCase == (int)performanceResult.TestCase && r.TestScenario == (int)performanceResult.TestScenario); if (testResults.Any()) { return(testResults.Max(r => r.TestNumber) + 1); } return(1); }
internal static PerformanceResult RunPerfTest(int depth, Board board) { var performanceResult = new PerformanceResult(); DateTime startTime = DateTime.Now; performanceResult.Nodes = Performance(depth, board, ChessPieceColor.White); performanceResult.TimeSpan = (DateTime.Now - startTime); performanceResult.Depth = depth; return(performanceResult); }
public static PerformanceResult RunConcurrentPerformanceTest(int numIterations, int degreeParallelism, Action operation) { int i; var taskList = new Task <PerformanceResult> [degreeParallelism]; long startTime = HiResTimer.Ticks; int subIterations = numIterations / degreeParallelism; for (i = 0; i < degreeParallelism; i++) { var t = new Task <PerformanceResult>(() => RunPerformanceTest(subIterations, operation, true)); taskList[i] = t; } for (i = 0; i < degreeParallelism; i++) { taskList[i].Start(); } Task.WaitAll(taskList); long stopTime = HiResTimer.Ticks; var rawData = new List <double>(); for (i = 0; i < degreeParallelism; i++) { rawData.AddRange(taskList[i].Result.DescriptiveResult.RawData); } var desc = new DescriptiveAnalysis(rawData); desc.Analyze(false); desc.AnalyzeHistogram(cHistogramBuckets); var res = new PerformanceResult { IsValid = true, Iterations = taskList.Sum(p => p.Result.Iterations), DegreeOfParallelism = degreeParallelism, TotalMilliseconds = ConvertToMs(startTime, stopTime), TotalSeconds = ConvertToSeconds(startTime, stopTime), TotalTicks = stopTime - startTime, DescriptiveResult = desc.Result }; for (i = 0; i < degreeParallelism; i++) { taskList[i].Dispose(); } return(res); }
public PerformanceResult Measure(ISerializerAdapter serializer) { var result = new PerformanceResult(Name, serializer.Name, _measurementCount); try { Measure(serializer, result); } catch (Exception e) { result.Failure = e.Message; } return result; }
public void StopProfilers() { PerformanceResult report = null; MvcMiniProfiler.StopProfiler(); PerfLabsStopWatch.StopProfiler(); SaveToDataBase(); if (PerformanceLabsConfigurations.GenerateReport) { report = new PerformanceResult(); report.GenerateHtmlResultFile(); } }
public static PerformanceResult RunConcurrentPerformanceTest(int numIterations, int degreeParallelism, Func <bool> operation) { int i; var taskList = new Task <PerformanceResult> [degreeParallelism]; int subIterations = numIterations / degreeParallelism; for (i = 0; i < degreeParallelism; i++) { var t = new Task <PerformanceResult>(() => RunPerformanceTest(subIterations, operation, true)); taskList[i] = t; } for (i = 0; i < degreeParallelism; i++) { taskList[i].Start(); } Task.WaitAll(taskList); var rawData = new List <double>(); bool valid = true; for (i = 0; i < degreeParallelism; i++) { valid &= taskList[i].Result.IsValid; rawData.AddRange(taskList[i].Result.DescriptiveResult.RawData); } var desc = new DescriptiveAnalysis(rawData); desc.Analyze(false); desc.AnalyzeHistogram(cHistogramBuckets); var res = new PerformanceResult { IsValid = valid, TotalMilliseconds = taskList.Max(p => p.Result.TotalMilliseconds), TotalSeconds = taskList.Max(p => p.Result.TotalSeconds), TotalTicks = taskList.Max(p => p.Result.TotalTicks), DescriptiveResult = desc.Result }; for (i = 0; i < degreeParallelism; i++) { taskList[i].Dispose(); } return(res); }
private static string GetColor(Func <PerformanceResult, double> valueGetter, PerformanceResult result, double min) { string color = null; if (result.Failure != null) { color = "red"; } else if (Equals(valueGetter(result), min)) { color = "DarkSeaGreen"; } return(color); }
public PerformanceResult Measure(ISerializerAdapter serializer) { var result = new PerformanceResult(Name, serializer.Name, _measurementCount); try { Measure(serializer, result); } catch (Exception e) { result.Failure = e.Message; } return(result); }
public bool IsPerformanceReady() { // Force keyboard up if (Properties.Settings.Default.ForcedOpen) { return(true); } if (Reader.CanGetPerformance()) { PerformanceResult res = Reader.GetPerformance(); return(res.IsUp()); } return(false); }
/// <summary> /// The main method /// </summary> public PerformanceResult Run() { // Init TimeStart = DateTime.Now; int itemCount = Instance.Pieces.Count(); int containerCount = Instance.Containers.Count(); // Start solving process Config.StartTimeStamp = DateTime.Now; // Main solve part Solve(); // End solving process DateTime afterTimeStamp = DateTime.Now; // Return performance result PerformanceResult result = new PerformanceResult() { BestBound = double.NaN, // Unavailable Gap = double.NaN, // Unavailable Instance = Instance, Solution = Solution, SolutionTime = afterTimeStamp - Config.StartTimeStamp, ObjectiveValue = Solution.VolumeContained }; // Log timestamp Config.LogSolutionStatus?.Invoke((DateTime.Now - Config.StartTimeStamp).TotalSeconds, Solution.ExploitedVolume); // Log finish if (Config.Log != null) { Config.Log(".Fin.\n"); Config.Log("Instance contained " + itemCount + " pieces and " + containerCount + " container\n"); Config.Log("Solution uses " + Solution.NumberOfContainersInUse + " containers and packed " + Solution.NumberOfPiecesPacked + " pieces\n"); Config.Log("Volume utilization: " + Solution.VolumeContained.ToString(ExportationConstants.EXPORT_FORMAT_SHORT, ExportationConstants.FORMATTER) + " / " + Solution.VolumeOfContainers.ToString(ExportationConstants.EXPORT_FORMAT_SHORT, ExportationConstants.FORMATTER) + " (" + ((Solution.VolumeContained / Solution.VolumeOfContainers) * 100).ToString(ExportationConstants.EXPORT_FORMAT_SHORT, ExportationConstants.FORMATTER) + "%)\n"); Config.Log("Volume utilization (used containers): " + Solution.VolumeContained.ToString(ExportationConstants.EXPORT_FORMAT_SHORT, ExportationConstants.FORMATTER) + " / " + Solution.VolumeOfContainersInUse.ToString(ExportationConstants.EXPORT_FORMAT_SHORT, ExportationConstants.FORMATTER) + " (" + ((Solution.VolumeContained / Solution.VolumeOfContainersInUse) * 100).ToString(ExportationConstants.EXPORT_FORMAT_SHORT, ExportationConstants.FORMATTER) + "%)\n"); Config.Log("Time consumed: " + result.SolutionTime.ToString()); } // Return return(result); }
/// <summary> /// Handle a sql string and check it with the engine /// </summary> /// <param name="actual">SQL string</param> /// <returns>true, if the query defined in parameter is executed in less that expected else false</returns> public bool doMatch(IDbCommand actual) { var engine = GetEngine(actual); if (cleanCache) { engine.CleanCache(); } performanceResult = engine.CheckPerformance(timeOutMilliSeconds); return ( performanceResult.TimeElapsed.TotalMilliseconds < maxTimeMilliSeconds && !performanceResult.IsTimeOut ); }
private void Reset() { hasScanned = false; isLoggedIn = false; logItems.Clear(); completeLog.Clear(); _previousArrayIndex = 0; _previousOffset = 0; currentPlayer = new CurrentPlayerResult(); party = new PartyResult(); actors = new ActorResult(); performance = new PerformanceResult(); }
public bool doMatch(IQuery actual) { var engine = GetEngine(actual); if (cleanCache) { engine.CleanCache(); } performanceResult = engine.Execute(new TimeSpan(0, 0, 0, 0, timeOutMilliSeconds)); return ( performanceResult.TimeElapsed.TotalMilliseconds < maxTimeMilliSeconds && !performanceResult.IsTimeOut ); }
public void CSharpTestOperation1_SmallTimeAndBigTimeForRegression_ShouldBeCapturedByMiniProfiler() { //profiling 10 times using smallTime -> emulating several correct response times TestHelper.ProfileMultipleTimes("CSharpTestOperation5", () => sampleCode.CSharpTestOperation1(true), 10, Profiler.MVCMiniProfiler); //emulating spike in response time TestHelper.ProfileMultipleTimes("CSharpTestOperation5", () => sampleCode.CSharpTestOperation1(false), 1, Profiler.MVCMiniProfiler); PerformanceResult pResult = new PerformanceResult(); IEnumerable <RegressionResult2> regressionResult2 = pResult.GetRegressionResult2(); pResult.PopulateListForMiniProfilerCodeRegressions(regressionResult2); Assert.IsTrue(pResult.ListCodeRegressions.First().Name == "CSharpTestOperation5"); pResult.Dispose(); }
public void Log(PerformanceResult report) { _targets.ForEach(target => { try { target.Log(report); } catch (Exception ex) { if (_logger != null) { _logger.LogWarning(ex, $"Failed to log the report on {report.EventId} to the target {target.GetType()}."); } } }); }
public void Record(PerformanceResult performanceResult) { using (var ctx = new Entities()) { ctx.PartIResult.Add(new PartIResult { TestNumber = GenerateNewTestNumber(ctx, performanceResult), DataBaseType = (int)dataBaseType, DateTimeAdded = DateTime.Now, TestCase = (int)performanceResult.TestCase, TestScenario = (int)performanceResult.TestScenario, ExecutionTime = performanceResult.ExecutionTime, }); ctx.SaveChanges(); } }
public void SqlConnectionTestOperation_SmallTimeAndBigTimeForRegression_DbRegressionShouldBeCapturedByMiniProfiler() { //profiling 10 times using smallTime -> emulating several correct response times TestHelper.ProfileMultipleTimes("SqlConnectionTestOperation1", () => sampleCode.SqlConnectionTestOperation(true), 15, Profiler.MVCMiniProfiler); //emulating spike in response time TestHelper.ProfileMultipleTimes("SqlConnectionTestOperation1", () => sampleCode.SqlConnectionTestOperation(false), 1, Profiler.MVCMiniProfiler); PerformanceResult pResult = new PerformanceResult(); IEnumerable <RegressionResult3> regressionResult3 = pResult.GetRegressionResult3(); pResult.PopulateListForDbRegressions(regressionResult3); Assert.IsTrue(pResult.ListDbRegression.First().Name == "SqlConnectionTestOperation1"); pResult.Dispose(); }
private void ValidateSerializer(ISerializerAdapter serializer, MemoryStream stream, PerformanceResult result) { long operationTime; Serialize(serializer, stream, out operationTime); result.Size = stream.Length; object deserialized = Deserialize(serializer, stream, out operationTime); var deserializedEnumerable = deserialized as IEnumerable; if (deserializedEnumerable != null) { if (!deserializedEnumerable.OfType<object>().SequenceEqual(((IEnumerable)GetValue()).OfType<object>())) throw new Exception("Deserialized object does not equal expected one"); } else if (!Equals(deserialized, GetValue())) throw new Exception("Deserialized object does not equal expected one"); }
public PerformanceResult Map(List <CryptoPrice> prices, string name, decimal currentAssetValue) { var result = new PerformanceResult { BaseCurrency = prices.First().BaseCurrency, QuoteCurrency = prices.First().QuoteCurrency, Name = name, ThreeMonthGainLoss = CalculateGainLoss(prices, 4, currentAssetValue), SixMonthGainLoss = CalculateGainLoss(prices, 7, currentAssetValue), OneYearGainLoss = CalculateGainLoss(prices, 13, currentAssetValue), ThreeYearGainLoss = CalculateGainLoss(prices, 37, currentAssetValue), FiveYearGainLoss = CalculateGainLoss(prices, 61, currentAssetValue) }; return(result); }
public static AnalyzerTaskResult CreateForPrepare(ProcedureContext procedureContext) { #region Argument exceptions if (procedureContext == null) { throw new ArgumentNullException("procedureContext"); } #endregion return(new AnalyzerTaskResult() { Performance = PerformanceResult.CreateForPrepare(procedureContext), Profiler = ProfilerResult.CreateForPrepare(procedureContext), QueryResult = default(DataTable) }); }
public async Task <PerformanceResult> Run() { var result = new PerformanceResult(); var responseBytes = 0; result.Times = new List <double>(); var swatchReq = Stopwatch.StartNew(); for (var index = 0; index < Runs; index++) { swatchReq.Restart(); if (_useRandom) { Query = PerfCommand.NextDomainName(); } try { var resultCount = await ExcecuteIterationAsync(); var responseElapsed = swatchReq.ElapsedTicks / 10000d; result.Times.Add(responseElapsed); if (resultCount <= 0) { result.ErrorResponses++; } else { Interlocked.Add(ref responseBytes, resultCount); } } catch { result.ErrorResponses++; } } result.TimeTakenMs = (long)result.Times.Sum(); result.SuccessResponses = responseBytes; return(result); }
private PerformanceResult[] LoadResultsFromVersionFolder(string performanceFolder, string path) { int v = int.Parse(Path.GetFileName(path)); string[] files = Directory.GetFiles(path, "*.xml", SearchOption.TopDirectoryOnly); PerformanceResult[] ret = new PerformanceResult[files.Length]; XmlSerializer xs = new XmlSerializer(typeof(PerformanceResult)); for (int i = 0; i < files.Length; i++) { Stream s = File.OpenRead(files[i]); ret[i] = (PerformanceResult)xs.Deserialize(s); ret[i].Version = v; ret[i].PerformanceFolder = performanceFolder; s.Close(); } return(ret); }
private void Measure(ISerializerAdapter serializer, PerformanceResult result) { GC.Collect(); using (var stream = new MemoryStream()) { ValidateSerializer(serializer, stream, result); for (int i = 0; i < _measurementCount; ++i) { long operationTime; Serialize(serializer, stream, out operationTime); result.SerializeTime.Add(operationTime); Deserialize(serializer, stream, out operationTime); result.DeserializeTime.Add(operationTime); } } result.SerializeTime.Compact(); result.DeserializeTime.Compact(); }
private void LocalOrchestraUpdate(List <ActorItem> actors) { if (Sharlayan.Reader.CanGetPerformance()) { PerformanceResult performance = Sharlayan.Reader.GetPerformance(); foreach (ActorItem actor in actors) { uint perfId = actor.PerformanceID / 2; if (perfId < 99) { PerformanceItem item = performance.Performances[perfId]; BmpLocalPerformer perf = LocalOrchestra.FindPerformer(actor.Name); if (perf != null) { perf.UiEnabled = item.IsReady(); } //Console.WriteLine(string.Format("{1} ({0}) => {2}", actor.ID, actor.Name, item.IsReady())); } } } }