-
Notifications
You must be signed in to change notification settings - Fork 0
/
NullCounters.ts
80 lines (71 loc) · 2.09 KB
/
NullCounters.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/** @module count */
import { Timing } from './Timing';
import { ICounters } from './ICounters';
/**
* Dummy implementation of performance counters that doesn't do anything.
*
* It can be used in testing or in situations when counters is required
* but shall be disabled.
*
* @see [[ICounters]]
*/
export class NullCounters implements ICounters {
/**
* Creates a new instance of the counter.
*/
public NullCounters() { }
/**
* Begins measurement of execution time interval.
* It returns [[Timing]] object which has to be called at
* [[Timing.endTiming]] to end the measurement and update the counter.
*
* @param name a counter name of Interval type.
* @returns a [[Timing]] callback object to end timing.
*/
public beginTiming(name: string): Timing {
return new Timing();
}
/**
* Calculates min/average/max statistics based on the current and previous values.
*
* @param name a counter name of Statistics type
* @param value a value to update statistics
*/
public stats(name: string, value: number): void { }
/**
* Records the last calculated measurement value.
*
* Usually this method is used by metrics calculated
* externally.
*
* @param name a counter name of Last type.
* @param value a last value to record.
*/
public last(name: string, value: number): void { }
/**
* Records the current time as a timestamp.
*
* @param name a counter name of Timestamp type.
*/
public timestampNow(name: string): void { }
/**
* Records the given timestamp.
*
* @param name a counter name of Timestamp type.
* @param value a timestamp to record.
*/
public timestamp(name: string, value: Date): void { }
/**
* Increments counter by 1.
*
* @param name a counter name of Increment type.
*/
public incrementOne(name: string): void { }
/**
* Increments counter by given value.
*
* @param name a counter name of Increment type.
* @param value a value to add to the counter.
*/
public increment(name: string, value: number): void { }
}