mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
Replace all Stopwatch with Timeit
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user