Navigation
Synopsis System time in nanoseconds (10-9 sec).
Function
  1. int systemTime()
  2. int systemTime(void () block)
Usage import util::Benchmark;
Description
  1. Current system time in nanoseconds (10-9 sec) since the start of the thread that runs the code that calls this function.
  2. System time in nanoseconds needed to execute the code block.
Examples We use the factorial function described in Recipes:Factorial as example:
rascal>import util::Benchmark;
ok
rascal>import demo::basic::Factorial;
ok
Here we measure time by using separate calls to sytemTime before and after a call to fac.
rascal>before = systemTime();
int: 3160905000
rascal>fac(50);
int: 30414093201713378043612608166064768844377641568960512000000000000
rascal>systemTime() - before;
int: 961000
The code to be measured can also be passed as a function parameter to systemTime:
rascal>systemTime( void() { fac(50); } );
int: 9000
Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit ask.rascal-mpl.org.