/
n-dimens
/
pascalabcnet
Обзор
Документация
Войти
/
n-dimens
/
pascalabcnet
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Debugger.Core/Src/Util/HighPrecisionTimer.cs
50 строк
1 KB
Бондарев Иван
initial commit
14 май 2015, 22:35
14 май 2015, 22:35
e6e67c1
Код
Авторство
О чём код?
// <file> // <copyright see="prj:///doc/copyright.txt"/> // <license see="prj:///doc/license.txt"/> // <owner name="David Srbecký" email="dsrbecky@gmail.com"/> // <version>$Revision: 2210 $</version> // </file> using System; using System.Runtime.InteropServices; namespace Debugger.Util { /// <summary> /// HighPrecisionTimer can obtain much more accurate time measurement /// for performace optimization /// </summary> public static class HighPrecisionTimer { [DllImport("kernel32.dll")] static extern int QueryPerformanceFrequency(out long frequency); [DllImport("kernel32.dll")] static extern int QueryPerformanceCounter(out long count); static DateTime startTime; static long startTicks; static HighPrecisionTimer() { startTime = DateTime.Now; startTicks = Ticks; } static long Ticks { get { long frequency; long count; QueryPerformanceFrequency(out frequency); QueryPerformanceCounter(out count); return (count / frequency) * TimeSpan.TicksPerSecond + (count % frequency) * TimeSpan.TicksPerSecond / frequency; } } public static DateTime Now { get { return startTime.AddTicks(Ticks - startTicks); } } } }