Obviously I can do and DateTime.Now.After
- DateTime.Now.Before
but there must be something more sophisticated.
Any tips appreciated.
This question is related to
c#
performance
benchmarking
execution-time
Tickcount is good, however i suggest running it 100 or 1000 times, and calculating an average. Not only makes it more measurable - in case of really fast/short functions, but helps dealing with some one-off effects caused by the overhead.
I would definitely advise you to have a look at System.Diagnostics.Stopwatch
And when I looked around for more about Stopwatch I found this site;
There mentioned another possibility
Process.TotalProcessorTime
Use a Profiler
Your approach will work nevertheless, but if you are looking for more sophisticated approaches. I'd suggest using a C# Profiler.
The advantages they have is:
There are many available open-source as well.
I would definitely advise you to have a look at System.Diagnostics.Stopwatch
And when I looked around for more about Stopwatch I found this site;
There mentioned another possibility
Process.TotalProcessorTime
Tickcount is good, however i suggest running it 100 or 1000 times, and calculating an average. Not only makes it more measurable - in case of really fast/short functions, but helps dealing with some one-off effects caused by the overhead.
Use a Profiler
Your approach will work nevertheless, but if you are looking for more sophisticated approaches. I'd suggest using a C# Profiler.
The advantages they have is:
There are many available open-source as well.
Use a Profiler
Your approach will work nevertheless, but if you are looking for more sophisticated approaches. I'd suggest using a C# Profiler.
The advantages they have is:
There are many available open-source as well.
Tickcount is good, however i suggest running it 100 or 1000 times, and calculating an average. Not only makes it more measurable - in case of really fast/short functions, but helps dealing with some one-off effects caused by the overhead.
Use a Profiler
Your approach will work nevertheless, but if you are looking for more sophisticated approaches. I'd suggest using a C# Profiler.
The advantages they have is:
There are many available open-source as well.
Tickcount is good, however i suggest running it 100 or 1000 times, and calculating an average. Not only makes it more measurable - in case of really fast/short functions, but helps dealing with some one-off effects caused by the overhead.
I would definitely advise you to have a look at System.Diagnostics.Stopwatch
And when I looked around for more about Stopwatch I found this site;
There mentioned another possibility
Process.TotalProcessorTime
Source: Stackoverflow.com