roverm
asked on
Strange delays in executing code
Hi all,
I've build an application which runs fine but for some reason on certain pc's it (much) slower. The pc's are exactly the same concerning the hardware.
To debug I have added traces and the delays seems to come... from nowhere!
On a slow pc the following code takes about 0,5 seconds to complete:
if (this.MyObject == null) { ... }
On a fast pc this takes milliseconds.
Any ideas on how to profile/debug/check this and more important, how to solve this?
Thanks!
D'Mzzl
RoverM
I've build an application which runs fine but for some reason on certain pc's it (much) slower. The pc's are exactly the same concerning the hardware.
To debug I have added traces and the delays seems to come... from nowhere!
On a slow pc the following code takes about 0,5 seconds to complete:
if (this.MyObject == null) { ... }
On a fast pc this takes milliseconds.
Any ideas on how to profile/debug/check this and more important, how to solve this?
Thanks!
D'Mzzl
RoverM
Well this.MyObject is (probably) a property and you are getting its value. A property can do a lot of processing and it is hidden from you when looking at the statement.
Check out what is happening by looking at the definition of the MyObject. Maybe something obvious will show.
Also, try breaking the line into two and see if the delay is in the 1st line (checking with the debugger):
var myObject = this.MyObject;
if (myObject == null) { ... }
Gary Davis
Check out what is happening by looking at the definition of the MyObject. Maybe something obvious will show.
Also, try breaking the line into two and see if the delay is in the 1st line (checking with the debugger):
var myObject = this.MyObject;
if (myObject == null) { ... }
Gary Davis
It sounds like an environmental problem. Checking/stopping the antivirus is a good step. The flipside is to make sure there is no malware present.
Check if the CPU is being pegged by any rogue apps.
Is the network working at decent speed?
Is the hard drive thrashing?
Perfmon can also be a useful tool for figuring out what's going on under the hood--looking at threading issues, or memory issues.
PerfMon – Your debugging buddy
Check if the CPU is being pegged by any rogue apps.
Is the network working at decent speed?
Is the hard drive thrashing?
Perfmon can also be a useful tool for figuring out what's going on under the hood--looking at threading issues, or memory issues.
PerfMon – Your debugging buddy
ASKER
Thanks for your responses.
Anti-Virus: This is a contained test, no anti-virus present. Also: Each machine is exactly the same.
Myobject is not a property, it's a class. So it's a reference to a pointer if it's checked for null.
Perfmon: I thought of that too but any suggestions on which counters to check?
Anti-Virus: This is a contained test, no anti-virus present. Also: Each machine is exactly the same.
Myobject is not a property, it's a class. So it's a reference to a pointer if it's checked for null.
Perfmon: I thought of that too but any suggestions on which counters to check?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The resource monitor and taskmanager is not showing anything unusual. I will try the perfmon to monitor it over time.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi all,
I have found the cause of the problem. Not by using any of your suggested solutions (that why I devided the point to the best suggestions) but by debugging.
The problem was the updating of the UI. At one point the mainform of the application was disabled (this.Enabled = false). This statement took milliseconds but as soon as .NET "thought" it had time to update the UI it blocked everything else. Once I remove this statement the speeds was the same on all pc's (fast!).
But I needed to disable/enable the mainform to prevent the user from entering information in an illegal state. I solved this by bringing an overlay (panel) to the front and push it back once done. This takes less than 1ms and does not block the UI.
Thanks for your suggestions.
D'Mzz!
RoverM
I have found the cause of the problem. Not by using any of your suggested solutions (that why I devided the point to the best suggestions) but by debugging.
The problem was the updating of the UI. At one point the mainform of the application was disabled (this.Enabled = false). This statement took milliseconds but as soon as .NET "thought" it had time to update the UI it blocked everything else. Once I remove this statement the speeds was the same on all pc's (fast!).
But I needed to disable/enable the mainform to prevent the user from entering information in an illegal state. I solved this by bringing an overlay (panel) to the front and push it back once done. This takes less than 1ms and does not block the UI.
Thanks for your suggestions.
D'Mzz!
RoverM
Antivirus is always something to consider as a cause for slow response. Try running the app with it shut down.
You could try running the app in safe mode also.