Class: Stopwatch

Stopwatch

Klasa's Stopwatch class, uses native node to replicate/extend previous performance now dependancy.

new Stopwatch( [digits])

Starts a new Stopwatch
Parameters:
Name Type Argument Default Description
digits number <optional>
2 The number of digits to appear after the decimal point when returning the friendly duration
Since:
  • 0.4.0
Source:
lib/util/Stopwatch.js#L13

Properties


digits :number

The number of digits to appear after the decimal point when returning the friendly duration.
Type:
  • number
Since:
  • 0.4.0
Source:
lib/util/Stopwatch.js#L35

<readonly> duration :number

The duration of this stopwatch since start or start to end if this stopwatch has stopped.
Type:
  • number
Since:
  • 0.4.0
Source:
lib/util/Stopwatch.js#L44

<readonly> friendlyDuration :string

The duration formatted in a friendly string
Type:
  • string
Since:
  • 0.4.0
Source:
lib/util/Stopwatch.js#L54

<readonly> running :boolean

If the stopwatch is running or not
Type:
  • boolean
Since:
  • 0.4.0
Source:
lib/util/Stopwatch.js#L67

Methods


reset()

Resets the Stopwatch to 0 duration (Returns a stopped state)
Since:
  • 0.4.0
Source:
lib/util/Stopwatch.js#L87
Returns:
Type
Stopwatch

restart()

Restarts the Stopwatch (Returns a running state)
Since:
  • 0.4.0
Source:
lib/util/Stopwatch.js#L76
Returns:
Type
Stopwatch

start()

Starts the Stopwatch
Since:
  • 0.4.0
Source:
lib/util/Stopwatch.js#L98
Returns:
Type
Stopwatch

stop()

Stops the Stopwatch, freezing the duration
Since:
  • 0.4.0
Source:
lib/util/Stopwatch.js#L111
Returns:
Type
Stopwatch

toString()

Defines toString behavior o return the friendlyDuration
Since:
  • 0.4.0
Source:
lib/util/Stopwatch.js#L121
Returns:
Type
string