Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

an instruction counting program 1

Status
Not open for further replies.

skata

Programmer
Oct 25, 2002
7
US
I am looking for a program that counts the instructions executed when running a program. Or if there is a way to doit without using a program (which it seems like there should be) I would like to learn how to do this.
 
I think you are looking for a profiler.

To be honest, the number of instructions executed is not especially interesting. Some instructions are preposterously slow compared to others, and most users are more interested in total execution time. What you probably need to know is how long your program is spending in its various functions?? (one obvious example: an op-code like rep movs can loop internally and move a massive chunk of memory in one go. It takes time, but it achieves the work of a lot of individual instructions).

It would, however, be fairly easy simply to count instructions. The 086 processors have a bit in their flag register called the trap bit, and if set, a particular interrupt is called after every single instruction. I don't know exactly how it behaves in protected mode. In old-fashioned 16-bit mode it used to be used by debuggers, because they could recover control after each instruction exectuted by another program. To count instructions you'd simply let the interrupt handler increment a counter each time the interrupt is called, before passing control back to the "counted" program.
 
Anyone know of a free, good profiler?
 
There's one that comes with Microsoft Visual C++ 6.0 (Professional Edition only, sorry)

[sub]I REALLY hope that helps.[/sub]
Will
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top