port from perforce

This commit is contained in:
2026-04-18 22:31:51 +02:00
commit 8d0ab5b7cc
8409 changed files with 3972376 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace Aiwaz.Common
{
public static class HiPerfTimer
{
[DllImport("Kernel32.dll")]
private static extern bool QueryPerformanceCounter(out long performanceCount);
[DllImport("Kernel32.dll")]
private static extern bool QueryPerformanceFrequency(out long frequency);
private static double? startTime;
private static double lastTime;
public static double LastDeltaTime
{
get;
private set;
}
public static double ElapsedTime
{
get
{
long frequency, performanceCount;
QueryPerformanceFrequency(out frequency);
QueryPerformanceCounter(out performanceCount);
double thisTime = performanceCount / (double)frequency;
if (!startTime.HasValue)
{
startTime = thisTime;
lastTime = thisTime;
return 0.0;
}
LastDeltaTime = thisTime - lastTime;
lastTime = thisTime;
return thisTime - startTime.Value;
}
}
}
}