Navigation
Synopsis User time in nanoseconds (10-9 sec).
Function
  1. int userTime()
  2. int userTime(void () block)
Usage import util::Benchmark;
Description
  1. Current time in nanoseconds (10-9 sec) since the start of the thread that runs the code that calls this function.
  2. User 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 userTime before and after a call to fac.
rascal>before = userTime();
int: 169265836000
rascal>fac(50);
int: 30414093201713378043612608166064768844377641568960512000000000000
rascal>userTime() - before;
int: 8934000
The code to be measured can also be passed as a function parameter to userTime:
rascal>userTime( void() { fac(50); } );
int: 686000
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.