public class EventCounter extends Metric
EventCounter treats events as instantaneous,
happening at a specific point in time and with no observable duration.
For observing events that have both frequency and duration, consider
a SessionCounter.| Modifier and Type | Field and Description |
|---|---|
protected EventCounterInterval |
mCurrentInterval |
protected long |
mNow |
protected EventCounterInterval |
mPeakEvents |
protected EventCounterInterval |
mPriorInterval |
intervalSeconds, startTime, totalIntervals| Constructor and Description |
|---|
EventCounter() |
EventCounter(String inLabel)
Constructs a new EventCounter with an interval duration of 1 second.
|
EventCounter(String inLabel,
int inIntervalSeconds)
Constructs an EventCounter with a specific interval duration.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(int inCount)
Adds a number events.
|
protected void |
createIntervals() |
long |
getCount()
Gets the total count of events.
|
long |
getCumulativeEvents()
Equivalent to getCount(), gets the total number of events added to this
EventCounter. |
float |
getCumulativeFreq()
Gets the overall event frequency for this
EventCounter |
float |
getCurrentFreq()
Gets the current event frequency for this
EventCounter. |
Interval |
getCurrentInterval()
Gets the current Interval, the one to which current events are added.
|
static EventCounter |
getEventCounter(String inLabel)
Get an instance of an EventCounter with a particular label from the
MetricRepository, creating one if necessary.
|
long |
getPeakEvents()
Gets the number of events that occurred during the interval in which the
most events occurred.
|
EventCounterInterval |
getPeakEventsInterval()
Gets the interval in which the greatest number of events were added.
|
void |
normalize()
Normalizes this EventCounter if necessary.
|
protected void |
normalizeCurrent_ScenarioA() |
protected void |
normalizeCurrent_ScenarioB() |
protected void |
normalizePrior_ScenarioA() |
protected void |
normalizePrior_ScenarioB(long nEmptyIntervals) |
void |
reset()
Reset this
EventCounter to its "zero" condition so that it can
be reused, avoiding the overhead of constructing a new instance. |
add, getAge, getAgeMillis, getIntervalSeconds, getLabel, getTotalIntervals, setLabel, uptimeprotected EventCounterInterval mCurrentInterval
protected EventCounterInterval mPriorInterval
protected EventCounterInterval mPeakEvents
protected long mNow
public EventCounter()
public EventCounter(String inLabel, int inIntervalSeconds)
inLabel - descriptive String used in reportinginIntervalSeconds - int duration of each interval in secondspublic EventCounter(String inLabel)
inLabel - descriptive String used in reportingpublic static EventCounter getEventCounter(String inLabel)
inLabel - Description of the Parameterpublic Interval getCurrentInterval()
public EventCounterInterval getPeakEventsInterval()
public long getPeakEvents()
getPeakEventsInterval().getEvents()public long getCount()
Metricpublic long getCumulativeEvents()
EventCounter.public float getCumulativeFreq()
EventCounterpublic float getCurrentFreq()
EventCounter. The
calculation includes the current incomplete interval. In order to reduce
excessive fluctuations when the current interval has just begun, the
immediately preceding interval, if one exists, is also included in the
calculation.public void add(int inCount)
public void normalize()
protected void normalizeCurrent_ScenarioA()
protected void normalizePrior_ScenarioA()
protected void normalizeCurrent_ScenarioB()
protected void normalizePrior_ScenarioB(long nEmptyIntervals)
public void reset()
EventCounter to its "zero" condition so that it can
be reused, avoiding the overhead of constructing a new instance.protected void createIntervals()
Copyright © 2015. All rights reserved.