When attempting to investigate the runtime of various tasks using System.nanoTime()
, the value, when the input data-set is large enough, turns negative.
The example code used:
long start = System.nanoTime();
run();
long stop = System.nanoTime();
int diff = (int) (stop-start);
System.out.println(data_size+", "+diff);
The output, when invoking run()
on an increasingly big data-set, looks like this:
1, 80000
10, 4310000
50, 48077000
100, 171363000
250, 1061924000
500, 14018704
750, 998074408
1000, -41025184
1500, -81710664
2000, -273795736
2500, 768997600
3000, -39161248
Does this make sense to anyone?