I am using valgrind to profile a program. The valgrind measurements shows a wrong relative runtime - it seems from the callgrind log that function1 has a longer runtime than function 2, although when I use a simple timer without valgrind, I see the opposite. Is there any explanation to that? what can I do about it?
Asked
Active
Viewed 162 times
0
-
1callgrind measures the nr of instructions executed and optionally other things (jumps, cache access, ...) but this is all based on a simulation that is not necessarily representative of the real timing of the hardware. For example, pipe line, speculative execution, ... might heavily influence the real time used for some instructions/functions and this is not measured by callgrind. Despite this, in my experience, optimising your application using callgrind measurement is giving good results. – phd Jul 05 '21 at 08:56
-
The results are indeed generally good and reliable. However, this specific point bothers me. I forgot to mention that the runtime difference between this 2 functions is about 10 times. So the fact that valgrind measures function1 as longer is strange – Arik Vasserman Jul 05 '21 at 10:27