I think I must be misunderstanding something about R’s system.time() function. If I have the following code in a test.r:
for(i in 1:10)
{
print(system.time(testFunction()))
}
(where testFunction() is defined elsewhere, but contains some fairly computationally-intensive code), and run the code, but kill the job after the 1st loop, then receive the following output:
> source("test.r")
user system elapsed
280.388 2.622 288.155
Timing stopped at: 210.891 0.367 211.637
why is the value for ‘Timing Stopped’ less than the elapsed time for the function?
The timing restarts during the second loop, and since you killed it part way through, it will be less than what you timed for the full first loop.