[Mono-dev] Application performance benchmarking

Tomas Kalibera kalibera at nenya.ms.mff.cuni.cz
Tue Apr 11 06:13:30 EDT 2006


If you need better accuracy, you can read your CPU's hardware counters 
directly - that is what I do for  benchmarks. On Intel you can use the 
RDTSC instruction to get the value of the time stamp counter (number of 
cpu ticks). You can implement reading the counter in C, link it as a 
shared library, and then use the library from C# code  by DllImport. 
There will however be some overhead for the call itself.

Tomas

Andreas Nahr wrote:

> If you want to do simple timing then either do the 
> DateTime.Now-StartTime that you described or use Environment.TickCount.
> These work ok unless you need to time something very short (<100ms)
> You may also want to try to launch mono with the --profile switch if 
> you just want to see which functions take most of the time.
>
> Andreas
>
>> Hi,
>>
>> Does anyone know what is the best way to benchmark a C# app? I'm
>> specifically looking for something, that would tell me which part of the
>> code takes up lot of time, how long does a specific block of code take
>> to execute, etc.
>>
>> Is the method when I note DateTime.Now before the block of code and
>> after it do a subtraction of the current DateTime.Now to the previous
>> one accurate?
>>
>> Best,
>> Lukas
>>
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>>
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list





More information about the Mono-devel-list mailing list