Class FastTimer
- java.lang.Object
- 
- com.codahale.metrics.Timer
- 
- org.apache.bookkeeper.stats.codahale.FastTimer
 
 
- 
- All Implemented Interfaces:
- com.codahale.metrics.Counting,- com.codahale.metrics.Metered,- com.codahale.metrics.Metric,- com.codahale.metrics.Sampling
 
 public class FastTimer extends com.codahale.metrics.TimerA fast and (nearly) garbage-free Rate and Response Times Timer. FastTimer uses circular arrays which are allocated upfront. Timer updates or queries never allocate new objects and thus never create garbage. A small number of new objects are allocated for snapshots when calling getSnapshot().
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classFastTimer.BucketsDefines the response time buckets to use.
 - 
Constructor SummaryConstructors Constructor Description FastTimer()Constructs a new timer with default time window (60 seconds) and default time buckets (fine).FastTimer(int timeWindowSeconds, FastTimer.Buckets buckets)Constructs a new timer.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetBucket(long duration)Figure out which percentile bucket an event of a given duration belongs into.longgetBucketBound(int b)Returns the upper bucket bound (inclusive) of a given bucket.longgetBucketValue(int b)Returns the average value of a given bucket (the mean between its lower and upper bound).longgetCount()Returns the all-time count of events this timer has seen.doublegetFifteenMinuteRate()doublegetFiveMinuteRate()doublegetMeanRate()intgetNumberOfBuckets()Returns the number of response time buckets used by this timer.doublegetOneMinuteRate()doublegetRate(int seconds)Returns the average per-second rate of events this timer has seen.com.codahale.metrics.SnapshotgetSnapshot()Returns a snapshot of this timer.protected intgetTime()Returns the current absolute time (in seconds).voidupdate(long duration, java.util.concurrent.TimeUnit unit)Add an event to this timer.
 
- 
- 
- 
Constructor Detail- 
FastTimerpublic FastTimer() Constructs a new timer with default time window (60 seconds) and default time buckets (fine).
 - 
FastTimerpublic FastTimer(int timeWindowSeconds, FastTimer.Buckets buckets)Constructs a new timer.- Parameters:
- timeWindowSeconds- the time window (in seconds) for this timer
- buckets- the type of buckets to use for response times
 
 
- 
 - 
Method Detail- 
getNumberOfBucketspublic int getNumberOfBuckets() Returns the number of response time buckets used by this timer.- Returns:
- the number of response time buckets
 
 - 
getBucketpublic int getBucket(long duration) Figure out which percentile bucket an event of a given duration belongs into.- Parameters:
- duration- the duration (in nanoseconds)
- Returns:
- the bucket
 
 - 
getBucketBoundpublic long getBucketBound(int b) Returns the upper bucket bound (inclusive) of a given bucket.- Parameters:
- b- the bucket
- Returns:
- the bound (in nanoseconds)
 
 - 
getBucketValuepublic long getBucketValue(int b) Returns the average value of a given bucket (the mean between its lower and upper bound).- Parameters:
- b- the bucket
- Returns:
- the average value (in nanoseconds)
 
 - 
getTimeprotected int getTime() Returns the current absolute time (in seconds).- Returns:
- the current absolute time (in seconds)
 
 - 
getRatepublic double getRate(int seconds) Returns the average per-second rate of events this timer has seen. The computed rate is calculated for past seconds (not including the current second, which is still being updated). If the specified time exceeds the time window of this timer, the only rate of the configured time window is reported.- Parameters:
- seconds- the number of seconds over which to calculate the average rate
- Returns:
- the average rate (per second).
 
 - 
getCountpublic long getCount() Returns the all-time count of events this timer has seen.- Specified by:
- getCountin interface- com.codahale.metrics.Counting
- Specified by:
- getCountin interface- com.codahale.metrics.Metered
- Overrides:
- getCountin class- com.codahale.metrics.Timer
- Returns:
- the all-time count of events
 
 - 
getFifteenMinuteRatepublic double getFifteenMinuteRate() - Specified by:
- getFifteenMinuteRatein interface- com.codahale.metrics.Metered
- Overrides:
- getFifteenMinuteRatein class- com.codahale.metrics.Timer
 
 - 
getFiveMinuteRatepublic double getFiveMinuteRate() - Specified by:
- getFiveMinuteRatein interface- com.codahale.metrics.Metered
- Overrides:
- getFiveMinuteRatein class- com.codahale.metrics.Timer
 
 - 
getMeanRatepublic double getMeanRate() - Specified by:
- getMeanRatein interface- com.codahale.metrics.Metered
- Overrides:
- getMeanRatein class- com.codahale.metrics.Timer
 
 - 
getOneMinuteRatepublic double getOneMinuteRate() - Specified by:
- getOneMinuteRatein interface- com.codahale.metrics.Metered
- Overrides:
- getOneMinuteRatein class- com.codahale.metrics.Timer
 
 - 
getSnapshotpublic com.codahale.metrics.Snapshot getSnapshot() Returns a snapshot of this timer. The computed snapshot is calculated over the complete time interval supported by this timer.- Specified by:
- getSnapshotin interface- com.codahale.metrics.Sampling
- Overrides:
- getSnapshotin class- com.codahale.metrics.Timer
- Returns:
- a snapshot of this timer
 
 - 
updatepublic void update(long duration, java.util.concurrent.TimeUnit unit)Add an event to this timer.- Overrides:
- updatein class- com.codahale.metrics.Timer
- Parameters:
- duration- the time duration of the event
- unit- the unit of time duration
 
 
- 
 
-