Skip to content

Timer

The timer module provides a simple interface for timing parts of flows. It is especially useful in combination with our Analytics product allowing you to time crucial parts of your flows.

Start

Start a named timer. If you invoke this method twice with the same name (argument) you’ll reset the timer every time.

Parameter

  • name the name of the timer to start

Example

javascript
Timer.start('myTimer');

Log

Log an event on a named timer. Useful only in combination with our Analytics product. The logged event will contain the name of the timer, the milliseconds since the timer was started and the given message.

Parameter

  • name the name of the timer to log an event on
  • message the message to log

Returns

The number of milliseconds since the timer was started.

Example

javascript
Timer.log('myTimer', 'A message goes here');

Stop

Stop a named timer.

Parameter

  • name the name of the timer to stop
  • log whether or not a message should be logged

Returns

The number of milliseconds since the timer was started.

Example

javascript
// Will log an event and stop 'myTimer'
Timer.stop('myTimer', true);