Re: Точное измерение производительности в дотнете
От: -kelvin-  
Дата: 12.08.05 14:22
Оценка:
Здравствуйте, VladD2, Вы писали:

VD>Utils.PerfCounter — простенький классик для точного замера производительности в дотнете.


The QueryPerformanceFrequency function retrieves the frequency of the high-resolution performance counter, if one exists. The frequency cannot change while the system is running.

Что если съэкономить на вызове QueryPerformanceFrequency:

public struct PerfCounter
{
Int64 _start;

public void Start()
{
_start = 0;
QueryPerformanceCounter(ref _start);
}

public float Finish()
{
Int64 finish = 0;
QueryPerformanceCounter(ref finish);

return (((float)(finish — _start) / PerfCounter.Frequency));
}

private static readonly float Frequency;
static PerfCounter()
{
Int64 freq = 0;
QueryPerformanceCounter(ref freq);
Frequency = (float)freq;
}

[DllImport("Kernel32.dll")]
static extern bool QueryPerformanceCounter(ref Int64 performanceCount);

[DllImport("Kernel32.dll")]
static extern bool QueryPerformanceFrequency(ref Int64 frequency);
}
Re[2]: Точное измерение производительности в дотнете
От: VladD2 Российская Империя www.nemerle.org
Дата: 13.08.05 08:28
Оценка:
Здравствуйте, -kelvin-, Вы писали:

K>Что если съэкономить на вызове QueryPerformanceFrequency:


Зачем?
... << RSDN@Home 1.2.0 alpha rev. 591>>
Есть логика намерений и логика обстоятельств, последняя всегда сильнее.
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.