As the other answer stated, it seems that the Windows timer does not have enough precision to measure execution time, i.e. execution time is < 1 nanosecond. If we make a simple change to the source of the package in the nanotimer.c
file to the do_microtiming()
C function...
if (start < end) {
const nanotime_t diff = end - start;
if (diff < overhead) {
ret[i] = R_NaReal;
n_under_overhead++;
} else {
ret[i] = diff - overhead;
}
} else if( start == end ) { // <----- This elseif is our minor edit
error( "Start and end have same time. Not enough precision to measure execution time" );
} else {
error("Measured negative execution time! Please investigate and/or "
"contact the package author.");
}
And then test it out...
f <- function() NULL
microbenchmark( f() )
#Error in microbenchmark(f()) :
# Start and end have same time. Not enough precision to measure execution time
It seems that you can't measure sub nanosecond times on yours (and mine) Windows system with current drivers.
So execution time is not negative, it's just so small you cannot measure it.