Files
PowerToys/Wox.Infrastructure/Timeit.cs

39 lines
909 B
C#
Raw Normal View History

using System;
2015-11-02 00:04:05 +00:00
using System.Collections.Generic;
using System.Diagnostics;
2015-11-02 00:04:05 +00:00
using Wox.Plugin;
namespace Wox.Infrastructure
{
public class Timeit : IDisposable
{
2015-11-02 00:04:05 +00:00
private readonly Stopwatch _stopwatch = new Stopwatch();
private readonly string _name;
public Timeit(string name)
{
2015-11-02 00:04:05 +00:00
_name = name;
_stopwatch.Start();
}
2015-11-02 00:04:05 +00:00
public long Current
{
get
{
_stopwatch.Stop();
long seconds = _stopwatch.ElapsedMilliseconds;
_stopwatch.Start();
2015-11-02 00:09:42 +00:00
Debug.WriteLine(_name + " : " + _stopwatch.ElapsedMilliseconds + "ms");
2015-11-02 00:04:05 +00:00
return seconds;
}
}
public void Dispose()
{
2015-11-02 00:04:05 +00:00
_stopwatch.Stop();
Debug.WriteLine(_name + ":" + _stopwatch.ElapsedMilliseconds + "ms");
}
}
}