[Mono-dev] Application performance benchmarking
jonpryor at vt.edu
Tue Mar 21 20:28:21 EST 2006
On Tue, 2006-03-21 at 21:51 +0100, Lukas Lipka wrote:
> 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.
You want a profiler. Mono includes several. You can specify which
profiler to use with the --profile argument, e.g.
mono --profile=default:stat,alloc program.exe
See the mono man page for more information.
> 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?
It's reasonably accurate. You should use DateTime.UtcNow instead of
DateTime.Now though, as it (purportedly) has less overhead associated
with the computation (because it doesn't need to shift timezones).
Note that for better accuracy you need large loops with this technique;
otherwise, the DateTime.UtcNow computation & assignment will be factors
in the overall timing.
More information about the Mono-devel-list