stats.BasicStat Extends
Tracks basic statistics over a specified time interval. Statistics are kept in a fixed number of slots, each representing an equal portion of the time interval. Most methods optionally allow passing in the current time, so that higher level stats can synchronize operations on multiple child objects. Under normal usage, the default of goog.now() should be sufficient.

Inheritance

Constructor

goog.stats.BasicStat(interval)

Parameters

interval : number
The stat interval, in milliseconds.

Instance Methods

Public Protected Private
checkForTimeTravel_(now)
Checks that time never goes backwards. If it does (for example, the user changes their system clock), the object state is cleared.
Arguments:
now : number
The current time, in milliseconds.
code »
get(opt_now) number
Returns the count of the statistic over its configured time interval.
Arguments:
opt_now : number=
The time, in milliseconds, to be treated as the "current" time. The current time must always be greater than or equal to the last time recorded by this stat tracker.
Returns: number  The total count over the tracked interval.
code »
getInterval() number
No description.
Returns: number  The interval which over statistics are being accumulated, in milliseconds.
code »
getMax(opt_now) number
Returns the magnitute of the largest atomic increment that occurred during the watched time interval.
Arguments:
opt_now : number=
The time, in milliseconds, to be treated as the "current" time. The current time must always be greater than or equal to the last time recorded by this stat tracker.
Returns: number  The maximum count of this statistic.
code »
getMin(opt_now) number
Returns the magnitute of the smallest atomic increment that occurred during the watched time interval.
Arguments:
opt_now : number=
The time, in milliseconds, to be treated as the "current" time. The current time must always be greater than or equal to the last time recorded by this stat tracker.
Returns: number  The minimum count of this statistic.
code »
getSlotBoundary_(time) number
Computes the end time for the slot that should contain the count around the given time. This method ensures that every bucket is aligned on a "this.slotInterval_" millisecond boundary.
Arguments:
time : number
The time to compute a boundary for.
Returns: number  The computed boundary.
code »
incBy(amtopt_now)
Increments the count of this statistic by the specified amount.
Arguments:
amt : number
The amount to increase the count by.
opt_now : number=
The time, in milliseconds, to be treated as the "current" time. The current time must always be greater than or equal to the last time recorded by this stat tracker.
code »
reduceSlots_(nowfuncval) number
Passes each active slot into a function and accumulates the result.
Arguments:
now : number | undefined
The current time, in milliseconds.
func : function(number, goog.stats.BasicStat.Slot_): number
The function to call for every active slot. This function takes two arguments: the previous result and the new slot to include in the reduction.
val : number
The initial value for the reduction.
Returns: number  The result of the reduction.
code »
reset_()
Clears any statistics tracked by this object, as though it were freshly created.
code »

Instance Properties

interval_ :
The time interval that this statistic aggregates over.
Code »
logger_ : goog.debug.Logger
No description.
Code »
slotInterval_ :
The number of milliseconds in each slot.
Code »
The array of slots.
Code »

Static Properties

goog.stats.BasicStat.NUM_SLOTS_ :
The number of slots. This value limits the accuracy of the get() method to (this.interval_ / NUM_SLOTS). A 1-minute statistic would be accurate to within 2 seconds.
Code »

Package stats

Package Reference