Skip to content

cla/util - General utilities namespace

General utilities.

util.sleep(seconds)

Stops execution during seconds. Seconds is a real number.

var util = require("cla/util");
util.sleep(1.5);

util.benchmark(n,code)

Executes the block of code a total of n times and prints the timing results. This is useful to help debug performance issues test how performant a code is before using it in production.

var util = require("cla/util");
util.benchmark(1000, function(){
    for( var i=0; i<100; i++) {
        var x = i * 2;
    }
});

Which prints out the following results (depending on your system performance):

timethis 100: 4 wallclock secs ( 4.16 usr + 0.03 sys = 4.19 CPU) @ 23.87/s (n=100)