forked from swharden/Spectrogram
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBenchmark.cs
More file actions
32 lines (28 loc) · 710 Bytes
/
Benchmark.cs
File metadata and controls
32 lines (28 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
using System.Diagnostics;
namespace Spectrogram
{
public class Benchmark : IDisposable
{
Stopwatch stopwatch;
bool silent;
public Benchmark(bool silent = false)
{
stopwatch = Stopwatch.StartNew();
this.silent = silent;
}
public double elapsedMilliseconds
{
get
{
return stopwatch.ElapsedTicks * 1000.0 / Stopwatch.Frequency;
}
}
public void Dispose()
{
stopwatch.Stop();
if (!silent)
Console.WriteLine(string.Format("completed in {0:0.00} ms", elapsedMilliseconds));
}
}
}