Use the gettimeofday()
(from sys/time.h
) to find the average running time of a given piece of code (the time_me()), by running it 10 times. The code provided in the link below defines a function time_me(). This function takes the parameter N as argument (integer argument) and is of type void.
You can find the function to be timed here: http://pastebin.com/r1JHP7Xu
Note: Also include the header "unistd.h" in your code. This is required for the sleep()
function.
N
, which is the parameter for the function. E.g. 7
time_me
takes the run, averaged of 10 calls to the function. E.g. 6.10
gettimeofday()
and other standard C functions