Class ProfilerBucket<T,S extends AbstractProfilerStat<T>>

java.lang.Object
io.higson.runtime.profiler.ProfilerBucket<T,S>
Type Parameters:
T - key type
S - statistics object type

public class ProfilerBucket<T,S extends AbstractProfilerStat<T>> extends Object
Lock-guarded bucket of statistics to be used by AbstractProfiler.
  • Constructor Details

    • ProfilerBucket

      public ProfilerBucket()
  • Method Details

    • addTime

      public void addTime(T key, long time, Function<T,S> keyStatSupplier)
      Adds [time] measured for given [key]. Updating statistics is guarded by [lock] dedicated for this bucket only. If there is no statistics object for [key] it will be created using provided [keyStatSupplier]
    • getStat

      public S getStat(T key, Function<S,S> copier)
      Gets statistics copy for given [key], or null if there is no statistics
    • getStats

      public List<S> getStats(Function<S,S> copier)
      Returns collection of all statistics held by this bucket.
    • clear

      public void clear()
      Removes all statistics from internal storage.