[ create a new paste ] login | about

Link: http://codepad.org/z6yQOoRf    [ raw code | fork ]

aaronla - C, pasted on Apr 24:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
static Tuple<TimeSpan, long> PerfTest(Action<long /*iterations*/> unitUnderTest)
{
  long n = 100;
  var sw = new StopWatch();

  unitUnderTest(10); // preheat
  for(;;) 
  {
    sw.Start();
    unitUnderTest(n);
    sw.Stop();

    if (sw.Elapsed.TotalSeconds < 1.0) {
        n *= 2;
        continue;
    }
    return Tuple.Create(sw.Elapsed, n);
  }
}

  


Create a new paste based on this one


Comments: