Console time for Java Script


I would like to check the time for some of my function, and use console.time() in Javascript. Is it possible to use this function on the contest ? If yes, how can we implement it ?

Currenlty, I add at the beginning of my function :


and at the end :


but I cannot see the time calculated in the log.

Thank you for your feedback.


Javascrit is running in a Nodejs 12.13.0 env ( ).

According to the documentation, console.timeEnd() will log out in stdout. No really a good thing for a codingame puzzle since we use stderr for debug logs.

I can suggest you to move to the perf_hooks module.

Basic usage:

require { performance } = require('perf_hooks');

const timer =;


console.error(`Time: ${ - timer}ms`);

You can also read the documentation to learn how PerformanceEntry and PerformanceObserver works. Pretty useful tool when you have to monitor a Nodejs code performances.

1 Like


Thank you Magus, it work perfectly (with one minor update as bellow) :

const { performance } = require(‘perf_hooks’);
const timer =;
console.error(Time: ${ - timer}ms);

I found another solution as well, but I don’t know which are the best compared to the previous one :

var end=;
var timeSpent=(end-begin)+" millisecs";

As far as i know, is faster than

1 Like