Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Pascal

Idiom #125 Measure function call duration

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

uses sysutils;
var
  t1, t: QWord;
begin
  t1 := GetTickCount64;
  foo;
  t := (GetTickCount64 - t1) * 1000000;
  writeln(t);
end.

GetTickCount64 returns milliseconds
(time (foo))

time prints time elapsed, but in ms

New implementation...
< >
JPSII