moved Log, Stopwatch to FileFormats. Added Support/Timer.

This commit is contained in:
Bob
2010-01-22 15:12:25 +13:00
parent cba37055e5
commit 8fd0e35d16
5 changed files with 75 additions and 2 deletions

View File

@@ -0,0 +1,33 @@
using System.Runtime.InteropServices;
namespace OpenRa.Support
{
public class Stopwatch
{
[DllImport("kernel32.dll")]
static extern bool QueryPerformanceCounter(out long value);
[DllImport("kernel32.dll")]
static extern bool QueryPerformanceFrequency(out long frequency);
long freq, start;
public Stopwatch()
{
QueryPerformanceFrequency(out freq);
QueryPerformanceCounter(out start);
}
public double ElapsedTime()
{
long current;
QueryPerformanceCounter(out current);
return (current - start) / (double)freq;
}
public void Reset()
{
QueryPerformanceCounter(out start);
}
}
}