Permalink
Browse files

View benchmark history

  • Loading branch information...
jskeet committed Jun 12, 2017
1 parent 247663b commit f66c054c03d698ee8f446222d7573d470505ce79
@@ -60,11 +60,21 @@ public IActionResult CompareTypes(string leftTypeId, string rightTypeId)
[Route("/benchmarks/benchmarks/{benchmarkId}")]
public IActionResult ViewBenchmark(string benchmarkId)
{
var benchmark = repository.GetBenchmark(benchmarkId);
var type = repository.GetType(benchmark.BenchmarkTypeId);
var run = repository.GetRun(type.BenchmarkRunId);
var env = repository.GetEnvironment(run.BenchmarkEnvironmentId);
return View((env, run, type, benchmark));
return View(LookupBenchmarkAndAncestors(benchmarkId));
}
[Route("/benchmarks/benchmarks/{benchmarkId}/history")]
public IActionResult ViewBenchmarkHistory(string benchmarkId)
{
var tuple = LookupBenchmarkAndAncestors(benchmarkId);
// Use the provided benchmark as the latest one to use
var benchmarks =
from run in tuple.environment.Runs.SkipWhile(r => r != tuple.run)
from type in run.Types_ where type.FullTypeName == tuple.type.FullTypeName
from benchmark in type.Benchmarks where benchmark.Method == tuple.benchmark.Method
select (run: run, benchmark: benchmark);
return View(benchmarks.ToList());
}
private (BenchmarkEnvironment environment, BenchmarkRun run, BenchmarkType type) LookupTypeAndAncestors(string typeId)
@@ -75,6 +85,15 @@ public IActionResult ViewBenchmark(string benchmarkId)
return (environment, run, type);
}
private (BenchmarkEnvironment environment, BenchmarkRun run, BenchmarkType type, Benchmark benchmark) LookupBenchmarkAndAncestors(string benchmarkId)
{
var benchmark = repository.GetBenchmark(benchmarkId);
var type = repository.GetType(benchmark.BenchmarkTypeId);
var run = repository.GetRun(type.BenchmarkRunId);
var environment = repository.GetEnvironment(run.BenchmarkEnvironmentId);
return (environment, run, type, benchmark);
}
private BenchmarkRun GetPreviousRun(BenchmarkRun run) =>
repository.GetEnvironment(run.BenchmarkEnvironmentId).Runs
.SkipWhile(r => r.BenchmarkRunId != run.BenchmarkRunId)
@@ -6,7 +6,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace NodaTime.Web.ViewModels
{
@@ -18,7 +18,8 @@
Type: <a href="/benchmarks/types/@type.BenchmarkTypeId">@type.FullTypeName</a><br />
Method: @benchmark.Method<br />
Environment: <a href="/benchmarks/environments/@env.BenchmarkEnvironmentId">@env.Machine, @env.TargetFramework</a><br />
Run: <a href="/benchmarks/runs/@run.BenchmarkRunId">@run.BenchmarkRunId.TruncateGuid()</a>
Run: <a href="/benchmarks/runs/@run.BenchmarkRunId">@run.BenchmarkRunId.TruncateGuid()</a> <br />
<a href="/benchmarks/benchmarks/@benchmark.BenchmarkId/history">View history (from here back)</a>
</p>
@if (benchmark.Statistics != null)
{
@@ -0,0 +1,37 @@
@using NodaTime.Benchmarks;
@model IEnumerable<(BenchmarkRun run, Benchmark benchmark)>
@{
ViewBag.Title = "Benchmark history";
var startBenchmark = Model.First().benchmark;
}
<div class="row">
<div>
<h1>Benchmark history</h1>
</div>
<div>
<p>
History of @startBenchmark.FullMethodName from <a href="/benchmarks/benchmarks/@startBenchmark.BenchmarkId">@startBenchmark.BenchmarkId.TruncateGuid()</a>
</p>
<table>
<tr>
<th>Run start (commit)</th>
<th>Mean</th>
<th>Standard error</th>
<th>Standard deviation</th>
</tr>
@foreach (var pair in Model)
{
<tr>
<td><a href="/benchmarks/runs/@pair.run.BenchmarkRunId">@Html.RenderTimestamp(@pair.run.Start)</a> (<a href="https://github.com/nodatime/nodatime/commit/@pair.run.Commit">@pair.run.Commit.TruncateCommit()</a>)</td>
<td>@Html.RenderTime(pair.benchmark.Statistics?.Mean)</td>
<td>@Html.RenderTime(pair.benchmark.Statistics?.StandardError)</td>
<td>@Html.RenderTime(pair.benchmark.Statistics?.StandardDeviation)</td>
</tr>
}
</table>
</div>
@* Work out how to style the above to leave some padding instead... *@
<p />
</div>

0 comments on commit f66c054

Please sign in to comment.