This returns the total elapsed time for the given timer, or the default total timer if no timer name is given.
Timer is a utility class to time events. It is available both on the server and the client.
A timer instance can be used in two ways:
- Regular Timer
const timer = new Tyr.Timer(); timer.start('initialize database'); ... initialize database ... timer.stop('initialize database'); ... timer.log();
- Stopwatch Timer
const timer = new Tyr.Timer(); ... task a .... timer.lap('task a'); ... task b ... timer.lap('task b'); ... task c ... timer.lap('task c'); ... timer.log();
This stops the given timer. If the timer was not started, the timer is considered to have been started when the last call to lap() was made (or when the timer was created if this is the first lap() call).
This logs the current timer status to the console.
This starts a timer with the given name, or if no name is provided, the default total timer.
This stops a timer with the given name, or if no name is provided, the default total timer.
This returns a summary of the current timers.