Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Throughput calculation using cycle count

Is it possible to determine the throughput of an application on a processor from the cycle counts (Processor instruction cycles) consumed by the application ? If yes, how to calculate it ?

like image 780
Karthik Balaguru Avatar asked Aug 15 '26 17:08

Karthik Balaguru


2 Answers

If the process is entirely CPU bound, then you divide the processor speed by the number of cycles to get the throughput.

In reality, few processes are entirely CPU bound though, in which case you have to take other factors (disk speed, memory speed, serialization, etc.) into account.

like image 117
Jerry Coffin Avatar answered Aug 17 '26 07:08

Jerry Coffin


Simple:

#include <time.h>
clock_t c;
c = clock(); // c holds clock ticks value
c = c / CLOCKS_PER_SEC; // real time, if you need it

Note that the value you get is an approximation, for more info see the clock() man page.

like image 31
Yuval Adam Avatar answered Aug 17 '26 07:08

Yuval Adam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!