Table of Contents

Syslog

This module binds the Hop.js builtin system time api. It enables measuring the execution time of a JavaScript fragment. It returns the result of the evaluation, the real time (wallclock time), the system time, and the user time.

Use require( hop.systime ) to use it.

Functions

systime.time(thunk)

Invoke the thunk procedure (a function with no argument) and returns an object describing the evaluation. Its properties are:

Example

This example shows how to measure a JavaScript execution time.

systime/systime.js

var Systime = require( hop.systime );

function fib( x ) {
   if( x < 2 ) {
      return 1;
   } else {
      return fib( x - 1 ) + fib( x - 2 );
   }
}

let o = Systime.time( function() { return fib( 30 ) } );

console.log( "res=", o.res, " real=", o.rtime, " stime=", o.stime, " utime=", o.utime );