public void Measure(string name, Action action) { RunSet runs; if (!this.operationruns.TryGetValue(name, out runs)) { this.operationruns[name] = runs = new RunSet(); } var sw = Stopwatch.StartNew(); action(); sw.Stop(); var r = new Run(); r.N = this.N; r.ExecutionTime = sw.Elapsed; runs.Runs.Add(r); }