|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.common.cache.CacheStats
@Beta public final class CacheStats
Statistics about the performance of a Cache
. Instances of this class are immutable.
Cache statistics are incremented according to the following rules:
hitCount
is incremented.
missCount
and loadSuccessCount
are
incremented, and the total loading time, in nanoseconds, is added to
totalLoadTime
.
missCount
and loadExceptionCount
are incremented, and the total loading time, in nanoseconds, is
added to totalLoadTime
.
missCount
.
evictionCount
is incremented.
Constructor Summary | |
---|---|
CacheStats(long hitCount,
long missCount,
long loadSuccessCount,
long loadExceptionCount,
long totalLoadTime,
long evictionCount)
Constructs a new CacheStats instance. |
Method Summary | |
---|---|
double |
averageLoadPenalty()
Returns the average time spent loading new values. |
boolean |
equals(Object object)
|
long |
evictionCount()
Returns the number of times an entry has been evicted. |
int |
hashCode()
|
long |
hitCount()
Returns the number of times Cache lookup methods have returned a cached value. |
double |
hitRate()
Returns the ratio of cache requests which were hits. |
long |
loadCount()
Returns the total number of times that Cache lookup methods attempted to load new
values. |
long |
loadExceptionCount()
Returns the number of times Cache lookup methods threw an exception while loading a
new value. |
double |
loadExceptionRate()
Returns the ratio of cache loading attempts which threw exceptions. |
long |
loadSuccessCount()
Returns the number of times Cache lookup methods have successfully loaded a new value. |
CacheStats |
minus(CacheStats other)
Returns a new CacheStats representing the difference between this CacheStats
and other . |
long |
missCount()
Returns the number of times Cache lookup methods have returned an uncached (newly
loaded) value, or null. |
double |
missRate()
Returns the ratio of cache requests which were misses. |
long |
requestCount()
Returns the number of times Cache lookup methods have returned either a cached or
uncached value. |
String |
toString()
|
long |
totalLoadTime()
Returns the total number of nanoseconds the cache has spent loading new values. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public CacheStats(long hitCount, long missCount, long loadSuccessCount, long loadExceptionCount, long totalLoadTime, long evictionCount)
CacheStats
instance.
Five parameters of the same type in a row is a bad thing, but this class is not constructed by end users and is too fine-grained for a builder.
Method Detail |
---|
public long requestCount()
Cache
lookup methods have returned either a cached or
uncached value. This is defined as hitCount + missCount
.
public long hitCount()
Cache
lookup methods have returned a cached value.
public double hitRate()
hitCount / requestCount
, or 1.0
when requestCount == 0
.
Note that hitRate + missRate =~ 1.0
.
public long missCount()
Cache
lookup methods have returned an uncached (newly
loaded) value, or null. Multiple concurrent calls to Cache
lookup methods on an absent
value can result in multiple misses, all returning the results of a single cache load
operation.
public double missRate()
missCount / requestCount
, or 0.0
when requestCount == 0
.
Note that hitRate + missRate =~ 1.0
. Cache misses include all requests which
weren't cache hits, including requests which resulted in either successful or failed loading
attempts, and requests which waited for other threads to finish loading. It is thus the case
that missCount >= loadSuccessCount + loadExceptionCount
. Multiple
concurrent misses for the same key will result in a single load operation.
public long loadCount()
Cache
lookup methods attempted to load new
values. This includes both successful load operations, as well as those that threw
exceptions. This is defined as loadSuccessCount + loadExceptionCount
.
public long loadSuccessCount()
Cache
lookup methods have successfully loaded a new value.
This is always incremented in conjunction with missCount
, though missCount
is also incremented when an exception is encountered during cache loading (see
loadExceptionCount
). Multiple concurrent misses for the same key will result in a
single load operation.
public long loadExceptionCount()
Cache
lookup methods threw an exception while loading a
new value. This is always incremented in conjunction with missCount
, though
missCount
is also incremented when cache loading completes successfully (see
loadSuccessCount
). Multiple concurrent misses for the same key will result in a
single load operation.
public double loadExceptionRate()
loadExceptionCount / (loadSuccessCount + loadExceptionCount)
, or
0.0
when loadSuccessCount + loadExceptionCount == 0
.
public long totalLoadTime()
loadSuccessCount
or loadExceptionCount
is incremented.
public double averageLoadPenalty()
totalLoadTime / (loadSuccessCount + loadExceptionCount)
.
public long evictionCount()
public CacheStats minus(CacheStats other)
CacheStats
representing the difference between this CacheStats
and other
. Negative values, which aren't supported by CacheStats
will be
rounded up to zero.
public int hashCode()
hashCode
in class Object
public boolean equals(@Nullable Object object)
equals
in class Object
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |