Class Synthetic
- java.lang.Object
-
- com.github.benmanes.caffeine.cache.simulator.Synthetic
-
public final class Synthetic extends Object
A generator of synthetic cache events to simulate different caching patterns.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static LongStreamcounter(int start, int events)Returns a sequence of unique integers.static LongStreamexponential(double mean, int events)Returns a sequence of events based on an exponential distribution.static TraceReader.KeyOnlyTraceReadergenerate(BasicSettings.TraceSettings settings)Returns a sequence of events based on the setting's distribution.static LongStreamhotspot(int lowerBound, int upperBound, double hotsetFraction, double hotOpnFraction, int events)Returns a sequence of events resembling a hotspot distribution where x% of operations access y% of data items.static LongStreamrepeating(int items, int events)Returns a repeating sequence of integers.static LongStreamscrambledZipfian(int items, double constant, int events)Returns a sequence of events where some items are more popular than others, according to a zipfian distribution.static LongStreamskewedZipfianLatest(int items, int events)Returns a zipfian sequence with a popularity distribution of items, skewed to favor recent items significantly more than older items.static LongStreamuniform(int lowerBound, int upperBound, int events)Returns a sequence of events where items are selected uniformly randomly from the interval inclusively.static LongStreamzipfian(int items, double constant, int events)Returns a sequence of events where some items are more popular than others, according to a zipfian distribution.
-
-
-
Method Detail
-
generate
public static TraceReader.KeyOnlyTraceReader generate(BasicSettings.TraceSettings settings)
Returns a sequence of events based on the setting's distribution.
-
counter
public static LongStream counter(int start, int events)
Returns a sequence of unique integers.- Parameters:
start- the number that the counter starts fromevents- the number of events in the distribution
-
repeating
public static LongStream repeating(int items, int events)
Returns a repeating sequence of integers.- Parameters:
items- the number of items in the distributionevents- the number of events in the distribution
-
uniform
public static LongStream uniform(int lowerBound, int upperBound, int events)
Returns a sequence of events where items are selected uniformly randomly from the interval inclusively.- Parameters:
lowerBound- lower bound of the distributionupperBound- upper bound of the distributionevents- the number of events in the distribution- Returns:
- a stream of cache events
-
exponential
public static LongStream exponential(double mean, int events)
Returns a sequence of events based on an exponential distribution. Smaller intervals are more frequent than larger ones, and there is no bound on the length of an interval.- Parameters:
mean- mean arrival rate of gamma (a half life of 1/gamma)events- the number of events in the distribution
-
hotspot
public static LongStream hotspot(int lowerBound, int upperBound, double hotsetFraction, double hotOpnFraction, int events)
Returns a sequence of events resembling a hotspot distribution where x% of operations access y% of data items. The parameters specify the bounds for the numbers, the percentage of the interval which comprises the hot set and the percentage of operations that access the hot set. Numbers of the hot set are always smaller than any number in the cold set. Elements from the hot set and the cold set are chosen using a uniform distribution.- Parameters:
lowerBound- lower bound of the distributionupperBound- upper bound of the distributionhotsetFraction- percentage of data itemhotOpnFraction- percentage of operations accessing the hot setevents- the number of events in the distribution
-
scrambledZipfian
public static LongStream scrambledZipfian(int items, double constant, int events)
Returns a sequence of events where some items are more popular than others, according to a zipfian distribution. Unlikezipfian(int, double, int), the generated sequence scatters the "popular" items across the item space. Use if you don't want the head of the distribution (the popular items) clustered together.- Parameters:
items- the number of items in the distributionconstant- the skew factor for the distributionevents- the number of events in the distribution
-
skewedZipfianLatest
public static LongStream skewedZipfianLatest(int items, int events)
Returns a zipfian sequence with a popularity distribution of items, skewed to favor recent items significantly more than older items.- Parameters:
items- the number of items in the distributionevents- the number of events in the distribution
-
zipfian
public static LongStream zipfian(int items, double constant, int events)
Returns a sequence of events where some items are more popular than others, according to a zipfian distribution.- Parameters:
items- the number of items in the distributionconstant- the skew factor for the distributionevents- the number of events in the distribution
-
-