Logo

Programming-Idioms

  • Lua
  • D

Idiom #125 Measure function call duration

measure the duration t, in nanoseconds, of a call to the function foo. Print this duration.

import std.datetime;
StopWatch sw;
sw.start;
foo;
auto t = sw.peek.nsecs; 
writeln(t);
(time (foo))

time prints time elapsed, but in ms

New implementation...
< >
JPSII