Reputation: 24067
While my application works, I've found that becomes unresponsive to any commands and the CPU is 100% utilized. I've used a profiler and found that 99% of the application's time is spent in one method (which is not expected).
I'm not sure if this method is being called repeatedly or "cycles" somewhere inside (or probably dead-lock).
I didn't get much information from the profiler results:
I don't understand why two lines close to each other have such different numbers (one 16% and the other 0.2%).
How can I figure out where the problem is?
Upvotes: 1
Views: 2806
Reputation: 40679
You are comparing curPrice
to moveTo
. Is either of those a property that may run off to do a lot of code, or has one of those overloaded the comparison operators? It looks like curPrice
is typically less than or equal to moveTo
, so it looks like it spends 16% of the time in the first comparison, then skipped...Bid
is easily tested, is > 0, and then it spends the same amount of time in the second curPrice
comparison as it did in the first.
That means you could potentially save up to 32% of the time by finding a faster way to do those comparisons. That's a speedup factor of 1/(1 - .32) = 1.47, or almost 50%.
I do a lot of performance tuning, and I don't use profilers. I use this method and so do some other people. If I took 10 stack samples of this code, on average 3.2 of them would show one or the other of those comparisons on the stack, and the reason why. It wouldn't give exact percents, but that doesn't matter - they're big enough to fix.
Upvotes: 0
Reputation: 24558
For a better profiling session, use Instrumentation : this will tell you how many times a method was called. You could also use this "call hierarchy" for detecting recursive calls.
EDIT : it's available in the wizard
Upvotes: 2