Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

total CPU instructions and total clock cycles used in xp OS

Status
Not open for further replies.

shakeel006

Junior Member level 3
Joined
Oct 31, 2004
Messages
28
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Pakistan
Activity points
249
I need to count number of cpu instructions used and clock cycles used on algorithm written in C++.

How can I count these two things

1. total CPU instructions used

2.total clock cycles used in xp operating systems

do I need to convert the C++ code to assembly using disassembler or any help tool or code in this regard will be highly appreciated

Thanks in Advance

Shakeel
 

i don't know the environment you are developing the program... but most IDE will be having features like Break and Stop Watch....

set the break point from where u have to calculate the instruction cycle and another at the end location...

run ur program in simulator mode.. when it reaches Start point, enable Stop watch and reset it ... continue simulation from start point.. the stop watch starts running with Time taken and instruction cycle count .. when it reaches End point, the simulation will stop,now stop watch will show you Instruction cycle and Time Taken
 

Re: total CPU instructions and total clock cycles used in xp

which IDE for c++ can the above task of calculating total CPU cycles of a particular code,which also has simulator for intel processor or can work in xp OS.


Thanks for your reply
 

i hope Visual studio C++ might having this feature...
I'm Embedded Software person and used these kind of things with cross-compilers....
 

Re: total CPU instructions and total clock cycles used in xp

It is not possible to get exact clock cycles on xp OS. It is not deterministic OS, and it is message driven, also every compiler is using its own optimization routines, so same code compiled on two different compilers result in different asm code.

there is though possibility to get clock cycles of wince 6 which is hard realtime system.
 

Re: total CPU instructions and total clock cycles used in xp

It's not possible to have exact calculations but approximate ones are possible.
1. total CPU instructions used
Yes. You do need to generate the assembly. I suppose you are not comparing compiler performance so you can say that for this compiler with these switches, the number of instructions are xxxx.

2.total clock cycles used in xp operating systems
You can use clock() API. It's resolution is in milliseconds. You can run your algo multiple times to get a relatively accurate time. Say you caculate time for 1000 runs of your algo. You'll then devide the result by 1000. it will give you more accurate result as compared to a single run of your algo. Once you get that time, you can calculate the clock cycles by multiplying it with processor frequency. Remember two things here
1) It will give right result for 1 single core CPU.
2) The frequency that we know as layman is not accurate one. A 2.2 GHz processor may actually be 2.17xxxx or 2.23xxxxx GHz.
 

Every flavor of Intel and AMD cpu will give you different cycle counts, also different SDRAM will causes different delays, and also there is lots of other interrupts running in the back ground, so it is not easy to determine.

Added after 1 minutes:

I think there is a 64-bit running cycle counter in newer Intel x86 processors. You capture it before you start and then again after you stop, then subtract and multiply it by the CPU core speed.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top