Reputation: 330882
I don't know if the title makes sense, but I am trying to time two different methods and see how many times they execute per second, or say per 10 seconds.
For instance:
DividePolygons1(Polygon[] polys)
DividePolygons2(Polygon[] polys)
DividePolygons1 ran:
1642 times per 1 second
DividePolygons2 ran:
1890 times per 1 second
Upvotes: 7
Views: 1936
Reputation: 554
Visual Studio 2010 has a profiler which could determine the exact number of methods calls per time unit.
Upvotes: 1
Reputation: 8269
What I would do:
Stopwatch
. Stopwatch
and check the TotalSeconds
against the variable I've been incrementing. Upvotes: 2
Reputation: 283624
The System.Diagnostics.Stopwatch
class will help you here, but be careful to use the results somehow so that the optimizer doesn't eliminate the logic you're trying to measure.
Beyond that, just run the code you're profiling several million times in a loop (adjust the iteration count to make it take between 1 and 30 seconds), then divide the number of iterations by the time taken to get the throughput in executions per second.
Upvotes: 10