Start your program running under the debugger. If it is a kind of program that normally runs very fast, but you want it to go faster, you can add a temporary outer loop of say, 1000 times, to give you enough time to halt it.
While it is being slow, halt it manually. Do this by striking a break or pause key that makes the program stop wherever it happens to be. Do not do this by setting a breakpoint in the code, because then you will not be able to see what it was doing when you struck the key.
Record the call stack. What you need to record is the file and line number of each statement on the call stack. Hopefully there is an easy way to copy-paste this information into a text editor, but if not, do it the hard way, with paper and pencil.
Restart it, halt it again, and record again. You can either continue execution from where you were, or completely restart the program. Either way is OK. You can do this several times, up to about 20.
Examine the call stack samples for common statements. You may find it helpful to group the call stack samples into an indented tree structure, so you can see the commonality between samples. It is important to remember that you are capturing statements, not functions. The line numbers are really important.
Examine statements that appear on multiple call stacks. These are your candidates for optimization. For example, if there is some statement at file Foo.cpp, line 127, that happens to show up on 8 out of 20 samples, then you should take a good look at that statement and see if what it is doing is really necessary, because if you could get rid of it, you would save about 40% of the execution time.
Fix the problem. And enjoy the speedup.
Do it all again, and again. Until you can't find anything else to optimize. Chances are your program is now many times faster than it was to begin with.
skip to main |
skip to sidebar
September 4, 2009
Subscribe to:
Post Comments (Atom)
Find Us On Facebook
Nepali News paper
Submit your site
computer
Custom Search
hit counter
My audio
Date convert BS. to AD
Blog Archive
-
▼
2009
(51)
-
▼
September
(24)
- How to Hack Windows
- Set up Your Laptop to Print Wirelessly
- Remotely Shut Down, Log Off, and Restart
- How to Find the IP Address of Your PC
- How to Block a Website in Internet Explorer
- Block and Accept Cookies in Internet Explorer
- How to Be Safe on the Internet
- How to Become a Computer Expert
- Change User Accounts Passwords Without Knowing the...
- How to Enter a Blocked Website
- Use Your Computer Without a Mouse
- How to Help Your Friend on the Computer
- How to Guess a Password
- How to Delete Personal Anti Virus Using MalWareBytes
- How to Appear Busy While Using a Computer
- How to Accept That Your Computer Is Slow
- How to Create Old Paper or Cloth Textures With Pho...
- How to Prepare a Program for Advanced Music Exams
- How to Optimize Your Program's Performance
- How to Become a Professional Web Designer and Prog...
- How to Become a Great Computer Programmer if You H...
- How to Become a Computer Scientist
- Rivers in Nepal
- Rafting in kaligandaki river
-
▼
September
(24)
No comments:
Post a Comment