Implements: ICounters
Description
The NullCounters class allows you to create dummy performance counters.
Important points
- It can be used in testing or in situations when a counter is required but must be disabled.
Instance methods
beginTiming
Begins measurement of execution time interval. It returns CounterTiming object which has to be called at CounterTiming.endTiming to end the measurement and update the counter.
public
beginTiming(name: string): CounterTiming: void
- name: string - a counter name of Interval type.
- returns: CounterTiming - a callback object to end timing.
increment
Increments counter by given value.
public
increment(name: string, value: number): void
- name: string - a counter name of Increment type.
- value: number - a value to add to the counter.
incrementOne
Increments counter by 1.
public
incrementOne(name: string): void
- name: string - a counter name of Increment type.
last
Records the last calculated measurement value. Usually this method is used by metrics calculated externally.
public
last(name: string, value: number): void
- name: string - a counter name of Last type.
- value: number - a last value to record.
stats
Calculates min/average/max statistics based on the current and previous values.
public
stats(name: string, value: number): void
- name: string - a counter name of Statistics type
- value: number - a value to update statistics
timestamp
Records the given timestamp.
public
timestamp(name: string, value: Date): void
- name: string - a counter name of Timestamp type.
- value: Date - a timestamp to record.
timestampNow
Records the current time as a timestamp.
public
timestampNow(name: string): void
- name: string - a counter name of Timestamp type.