public ActionResult BenchmarkRun(string machine, string label) { BenchmarkRun run = null; string nextLabel = null; // In descending label order, so earlier... foreach (var candidate in repository.RunsByMachine[machine]) { if (run != null) { nextLabel = candidate.Label; break; } if (candidate.Label == label) { run = candidate; } } ImmutableList <SourceLogEntry> changes = null; if (nextLabel != null) { string earlierHash = BenchmarkRepository.HashForLabel(nextLabel); string thisHash = BenchmarkRepository.HashForLabel(label); changes = log.EntriesBetween(earlierHash, thisHash).ToImmutableList(); } return(View(new BenchmarkRunAndSourceLogs(run, changes))); }
public BenchmarkDiff(BenchmarkRun left, BenchmarkRun right, ImmutableList <SourceLogEntry> log) { Left = left; Right = right; var leftResults = left.AllResults.ToList(); var rightResults = right.AllResults.ToList(); LeftOnly = leftResults.ExceptBy(rightResults, result => result.FullMethod); RightOnly = rightResults.ExceptBy(leftResults, result => result.FullMethod); var pairs = (from l in leftResults join r in rightResults on l.FullMethod equals r.FullMethod select new BenchmarkPair(l, r)).ToList(); LeftBetter = pairs.Where(pair => pair.Percent < ImprovementThreshold).ToList(); RightBetter = pairs.Where(pair => pair.Percent > RegressionThreshold).ToList(); bool leftEarlier = BenchmarkRepository.BuildForLabel(left.Label) < BenchmarkRepository.BuildForLabel(right.Label); var earlier = leftEarlier ? left : right; var later = leftEarlier ? right : left; var earlierHash = BenchmarkRepository.HashForLabel(earlier.Label); var laterHash = BenchmarkRepository.HashForLabel(later.Label); LogEntries = log.EntriesBetween(earlierHash, laterHash).ToList(); }
protected Decimal?TryGetTotalByBasket(CountryBasket basket, BenchmarkRepository benchmarkRepository, String benchmarkId) { var country = basket.Country; var result = this.TryGetTotalByCountry(country, benchmarkRepository, benchmarkId); return(result); }
protected Decimal?TryGetTotalByCountry(Aims.Core.Country country, BenchmarkRepository benchmarkRepository, String benchmarkId) { var benchmarkRecords = benchmarkRepository .GetBenchmarksByIsoCountryCode(country.IsoCode) .Where(x => x.BenchmarkId == benchmarkId); if (benchmarkRecords.Any()) { Decimal?result = null; foreach (var record in benchmarkRecords) { var value = record.BenchmarkWeight; if (value.HasValue) { if (result.HasValue) { result = result.Value + value.Value; } else { result = value.Value; } } else { // do nothing } } return(result); } else { return(null); } }
protected Decimal?TryGetTotalByBasket(RegionBasket basket, BenchmarkRepository benchmarkRepository, String benchmarkId) { Decimal?result = null; foreach (var country in basket.Countries) { var value = TryGetTotalByCountry(country, benchmarkRepository, benchmarkId); if (value.HasValue) { if (result.HasValue) { result = result.Value + value.Value; } else { result = value.Value; } } else { // do nothing } } return(result); }
public BenchmarksController() { string root = HostingEnvironment.ApplicationPhysicalPath; string benchmarkData = Path.Combine(root, "benchmarkdata"); repositoryWatcher = new FileWatchingReloader <BenchmarkRepository>( Path.Combine(benchmarkData, "index.txt"), () => BenchmarkRepository.Load(benchmarkData), ReloadTime); string logFile = Path.Combine(root, "hg-log.xml"); logWatcher = new FileWatchingReloader <MercurialLog>(logFile, () => MercurialLog.Load(logFile), ReloadTime); }
public static MethodHistoryModel ForMachineMethod(BenchmarkRepository repository, string machine, string method, bool allResults) { var runs = repository.RunsByMachine[machine]; List <Entry> entries = new List <Entry>(); BenchmarkResult previousResult = null; // Work things out in ascending time order, then reverse later. Too confusing otherwise! foreach (var run in runs.OrderBy(f => f.Start)) { var result = run.AllResults.FirstOrDefault(m => m.FullMethod == method); if (result == null && previousResult == null) { continue; } if (result == null) { entries.Add(new Entry(run, "Method removed")); } else if (allResults) { entries.Add(new Entry(run, result.NanosecondsPerCall + "ns")); } else if (previousResult == null) { entries.Add(new Entry(run, "Method introduced")); } else { // TODO: This only spots sudden improvements, not gradual improvements over time. Consider // remembering the "last change" result and using that instead. long percent = (result.PicosecondsPerCall * 100) / previousResult.PicosecondsPerCall; if (percent > BenchmarkDiff.RegressionThreshold) { entries.Add(new Entry(run, string.Format("Regression: {0}ns to {1}ns", previousResult.NanosecondsPerCall, result.NanosecondsPerCall))); } if (percent < BenchmarkDiff.ImprovementThreshold) { entries.Add(new Entry(run, string.Format("Improvement: {0}ns to {1}ns", previousResult.NanosecondsPerCall, result.NanosecondsPerCall))); } } previousResult = result; } entries.Reverse(); return(new MethodHistoryModel { Machine = machine, Method = method, Entries = entries.ToImmutableList(), AllResults = allResults }); }
public BenchmarkDiff(BenchmarkRun left, BenchmarkRun right, MercurialLog log) { Left = left; Right = right; LeftOnly = left.Results.ExceptBy(right.Results, result => result.FullyQualifiedMethod); RightOnly = right.Results.ExceptBy(left.Results, result => result.FullyQualifiedMethod); var pairs = (from l in left.Results join r in right.Results on l.FullyQualifiedMethod equals r.FullyQualifiedMethod select new BenchmarkPair(l, r)).ToList(); LeftBetter = pairs.Where(pair => pair.Percent < ImprovementThreshold).ToList(); RightBetter = pairs.Where(pair => pair.Percent > RegressionThreshold).ToList(); var earlier = left.StartTime < right.StartTime ? left : right; var later = left.StartTime < right.StartTime ? right : left; var earlierHash = BenchmarkRepository.HashForLabel(earlier.Label); var laterHash = BenchmarkRepository.HashForLabel(later.Label); LogEntries = log.EntriesBetween(earlierHash, laterHash).ToList(); }
public TrivialDependencyResolver() { string root = HostingEnvironment.ApplicationPhysicalPath; string benchmarkData = Path.Combine(root, "benchmarkdata"); /* * repositoryWatcher = new FileWatchingReloader<BenchmarkRepository>( * Path.Combine(benchmarkData, "index.txt"), * () => BenchmarkRepository.Load(benchmarkData), * ReloadTime);*/ repositoryWatcher = new FileWatchingReloader <BenchmarkRepository>( Path.Combine(benchmarkData, "benchmarks.xml"), () => BenchmarkRepository.LoadSingleFile(Path.Combine(benchmarkData, "benchmarks.xml")), ReloadTime); string hgLogFile = Path.Combine(root, "hg-log.xml"); string gitLogFile = Path.Combine(root, "git-log.txt"); var hgWatcher = new FileWatchingReloader <ImmutableList <SourceLogEntry> >(hgLogFile, () => MercurialLog.Load(hgLogFile), ReloadTime); var gitWatcher = new FileWatchingReloader <ImmutableList <SourceLogEntry> >(gitLogFile, () => GitLog.Load(gitLogFile), ReloadTime); logWatcher = new CombiningReloader <ImmutableList <SourceLogEntry> >(new[] { hgWatcher, gitWatcher }.ToImmutableList(), logs => logs.SelectMany(x => x).OrderByDescending(x => x.Date).ToImmutableList()); }
public BenchmarksController(BenchmarkRepository repository, ImmutableList <SourceLogEntry> log) { this.repository = repository; this.log = log; }
public TryGetTotalByBasket_IBasketResolver(BenchmarkInitializer initializer, BenchmarkRepository benchmarkRepository, String benchmarkId) { this.benchmarkRepository = benchmarkRepository; this.initializer = initializer; this.benchmarkId = benchmarkId; }
protected Decimal?TryGetTotalByBasketOnceResolved(IBasket basket, String benchmarkId, BenchmarkRepository benchmarkRepository) { var resolver = new TryGetTotalByBasket_IBasketResolver(this, benchmarkRepository, benchmarkId); basket.Accept(resolver); return(resolver.Result); }
public DashboardController(BenchmarkRepository repository) { _repository = repository; }