Benchmarking code - am I doing it right?
问题 I want to benchmark a C/C++ code. I want to measure cpu time, wall time and cycles/byte. I wrote some mesurement functions but have a problem with cycles/byte. To get a cpu time I wrote a function getrusage() with RUSAGE_SELF , for wall time i use clock_gettime with MONOTONIC , to get cycles/byte I use rdtsc . I process an input buffer of size, for example, 1024: char buffer[1024] . How do I benchmark: Do a warm-up phase, simply call fun2measure(args) 1000 times: for(int i=0; i<1000; i++)