Click here to Skip to main content
12,356,784 members (75,340 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

11K views
4 bookmarked
Posted

Debugging technique

, 27 Jan 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
Timing code using debugger
We can use ‘Watch’ window to get time information. An undocumented pseudoregister, @CLK, can serve as a timer. In many cases, we just want a rough idea of the time between two points, and @CLK makes it easy to find out how long it took to execute between two breakpoints. Please note that this time includes the debugger overhead. The trick is to enter @CLK in watch window, running time between two breakpoints will be added up to the current clock value. You can reset the value by typing @CLK=0 in watch window.
The time is in microseconds, to get time in milliseconds, set the @CLK to @CLK/1000. Although it is not a perfect timer, @CLK is good enough for some general guesses.

Example:-
BEGIN_CODE <- Add break point here (B1)
{
    <<Code block>>
}
END_CODE <- Add another break point here (B2)

Debug the code using F5. Once you reach B1, type @CLK in watch window which will display current clock value. Now type @CLK=0 in watch window to reset the clock. Now press F5to continue, once the control reaches B2, watch window will show the time taken for executing code block between B1 and B2.
Note: This will not include the break time @B1.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Junaij
Web Developer
India India
No Biography provided

You may also be interested in...

Comments and Discussions

 
GeneralReason for my vote of 5 Good trick! Pin
Starfair31-Jan-11 3:30
memberStarfair31-Jan-11 3:30 
GeneralReason for my vote of 5 Very useful.. Pin
Pravin Patil, Mumbai30-Jan-11 21:26
memberPravin Patil, Mumbai30-Jan-11 21:26 
GeneralInnovation trick... Take my 5. Pin
Pravin Patil, Mumbai30-Jan-11 21:26
memberPravin Patil, Mumbai30-Jan-11 21:26 
GeneralReason for my vote of 5 Useful trick! Pin
Sauro Viti29-Jan-11 11:03
memberSauro Viti29-Jan-11 11:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160621.1 | Last Updated 27 Jan 2011
Article Copyright 2011 by Junaij
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid