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
javascript
// Create and start a timer named 'myTimer'
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 onmessage
the message to log
Returns
The number of milliseconds since the timer was started.
javascript
// Log an event for the timer named 'myTimer' with a descriptive message
// Returns the number of milliseconds elapsed since the timer was started
Timer.log('myTimer', 'A message goes here');
Stop
Stop a named timer.
Parameter
name
the name of the timer to stoplog
whether or not a message should be logged
Returns
The number of milliseconds since the timer was started.
javascript
// Stop the timer named 'myTimer' and log a final event
// Returns the total elapsed time in milliseconds since the timer was started
Timer.stop('myTimer', true);