Replace all Stopwatch with Timeit

This commit is contained in:
bao-qian
2015-11-02 00:04:05 +00:00
parent 79fdba969b
commit bfa0db3ba3
3 changed files with 69 additions and 68 deletions

View File

@@ -1,23 +1,38 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Wox.Plugin;
namespace Wox.Infrastructure
{
public class Timeit : IDisposable
{
private Stopwatch stopwatch = new Stopwatch();
private string name;
private readonly Stopwatch _stopwatch = new Stopwatch();
private readonly string _name;
public Timeit(string name)
{
this.name = name;
stopwatch.Start();
_name = name;
_stopwatch.Start();
}
public long Current
{
get
{
_stopwatch.Stop();
long seconds = _stopwatch.ElapsedMilliseconds;
_stopwatch.Start();
Debug.WriteLine(_name + ":" + _stopwatch.ElapsedMilliseconds + "ms");
return seconds;
}
}
public void Dispose()
{
stopwatch.Stop();
Debug.WriteLine(name + ":" + stopwatch.ElapsedMilliseconds + "ms");
_stopwatch.Stop();
Debug.WriteLine(_name + ":" + _stopwatch.ElapsedMilliseconds + "ms");
}
}
}