Hi All..

I have developed a tool in C++ and I want to check the performance of the tool using callgrind.

For the first time I have executed my tool with different input sets and I have taken the number of instruction cycles as the referance for further usage.

Following are my referance results:
Expected Count : 14884726 - with one set of inputs
Expected Count : 16556159 - with another set of inputs
Expected Count : 15693275 - with another set of inputs

After getting this referance results I have re-run my tool with the same set of inputs for multiple times. For each time I am not getting the same (even Identicle) instruction cycle counts.
Following are the generated instruction cycle counts:

For first time

Generated Count : 14884568
Expected Count : 14884726

Generated Count : 16556023
Expected Count : 16556159

Generated Count : 15693195
Expected Count : 15693275

For second time

Generated Count : 14884590
Expected Count : 14884726

Generated Count : 16556050
Expected Count : 16556159

Generated Count : 15693241
Expected Count : 15693275

For Third time

Generated Count : 14884636
Expected Count : 14884726

Generated Count : 16556091
Expected Count : 16556159

Generated Count : 15693195
Expected Count : 15693275


I am using RHEL 5 machine. Is it OK to generate the number of instruction cycles with differance in 100s?

My Query is, I am using the same machine and running the same program with same input set, why this callgrind generating different instruction cycle counts. :?:

Thanks in advance.....

Recommended Answers

All 2 Replies

My guess is that the difference is due to running the program on a multi-threaded operating system such as *nix and MS-Windows. The operating system is doing a lot more things than just running your program.

As per my understandings, callgrind just counts the number of instructions that a program required to completes its execution.

For checking this I have written a simple program which allocates a bunch of memory and frees the allocated memory. I have printed the number of instruction cycles counted by callgrind. I am getting the same number for multiple times. Then I have tried to do the same allocation and freeing in a loop and execute the same program multiple times and I get the same instruction cycle count for each run.

The tool I am using is a single threaded tool. I think callgrind doesn't consider the instruction cycles required for swapping or operations done by OS for allocation and de allocating memory for the process.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.