Options
All
  • Public
  • Public/Protected
  • All
Menu

Represents a simle time counting object, that is able to determine temporal differences between start and end.

For a more complete implementation, see Timer.

example

Timing an operation

import {SimpleTimer} from "timecount";

const timer = new SimpleTimer({ autoStart: true });

// Operation code...

timer.end();
console.log(`It took ${timer.result.toString()} to do it.`);

Hierarchy

Index

Constructors

constructor

  • Initializes a new instance of the Timer class, optionally passing a configuration object as parameter.

    Parameters

    • Optional options: TimeOutputOptions

      An object with the options to configure the timer execution and output.

    Returns SimpleTimer

Accessors

elapsedTime

elapsedTime:

Gets the time span with the elapsed time so far.

endTime

endTime:

Gets a value representing the end time, in nanoseconds.

ended

ended:

Gets whether or not the time counting has ended.

options

options:

Gets the output options object used by this timer.

result

result:

Gets the result time span object from the time counting.

startTime

startTime:

Gets a value representing the start time, in nanoseconds.

started

started:

Gets whether or not the time counting has started.

Methods

end

  • Finishes the time counting, adjusting the time values and properties accordingly.

    Returns TimeSpan

    An object with the time span between start and end.

Protected setEndTime

  • setEndTime(value: number): void
  • Protected setter for the endTime property.

    Parameters

    • value: number

    Returns void

Protected setResult

  • Protected setter for the result property.

    Parameters

    Returns void

Protected setStartTime

  • setStartTime(value: number): void
  • Protected setter for the startTime property.

    Parameters

    • value: number

    Returns void

start

  • start(): void
  • Starts the time counting.

    Returns void

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc