@Override protected TimeStats initialValue() { return new TimeStats(); } };
/** * obtain elapsed nanoseconds for a specific key * * @param key * timer key * @return hit count for a specific key */ public long getAgeNanos(String key) { TimeStats last = EVENT_MAP.get(key); return last != null ? last.getAgeNanos() : 0; }
/** * obtain hit count for a specific key * * @param key * timer key * @return hit count for a specific key */ public long getHitCount(String key) { TimeStats last = EVENT_MAP.get(key); return last != null ? last.getHitCount() : 0; }
@Override public DumpCollection getDump() { Dump dump = new Dump(getCategoryName() + "-Table", this); for (Entry<String, TimeStats> entry : timeTracker.getTimeStats().entrySet()) { dump.add( entry.getKey(), "h(" + entry.getValue().getHitCount() + "-" + entry.getValue().getHitAge(TimeUnit.MILLISECONDS) + ")" + "m(" + entry.getValue().getMissCount() + "-" + entry.getValue().getMissAge(TimeUnit.MILLISECONDS) + ")"); } return dump; } }
/** * Miss and obtain miss count * * @param key * timer key * @return miss count */ public long missAndGetCount(String key) { TimeStats timeStats = EVENT_MAP.get(key); if (timeStats == null) { timeStats = EVENT_MAP.putIfAbsent(key, new TimeStats()); timeStats = timeStats == null ? EVENT_MAP.get(key) : timeStats; } timeStats.miss(); return timeStats.getMissCount(); }
/** * Hit and obtain hit count * * @param key * timer key * @return hit count */ public long hitAndGetCount(String key) { TimeStats timeStats = EVENT_MAP.get(key); if (timeStats == null) { timeStats = EVENT_MAP.putIfAbsent(key, new TimeStats()); timeStats = timeStats == null ? EVENT_MAP.get(key) : timeStats; } timeStats.hit(); return timeStats.getHitCount(); }
/** * Hit and obtain elapsed nanoseconds since last hit * * @param key * timer key * @return elapsed nanoseconds since last hit */ public long hitAndGet(String key) { TimeStats timeStats = EVENT_MAP.get(key); if (timeStats == null) { timeStats = EVENT_MAP.putIfAbsent(key, new TimeStats()); timeStats = timeStats == null ? EVENT_MAP.get(key) : timeStats; } return timeStats.hit(); }
/** * Miss and obtain elapsed nanoseconds since last miss * * @param key * timer key * @return elapsed nanoseconds since last miss */ public long missAndGet(String key) { TimeStats timeStats = EVENT_MAP.get(key); if (timeStats == null) { timeStats = EVENT_MAP.putIfAbsent(key, new TimeStats()); timeStats = timeStats == null ? EVENT_MAP.get(key) : timeStats; } return timeStats.miss(); }
/** * Hit this entry, time stamp it and count the number of hits * * @return elapsed nanoseconds since the last hit */ public long hit() { return hit(+1); }
/** * Miss this entry, time stamp it and count the number of miss * * @return elapsed nanoseconds since the last miss */ public long miss() { return miss(+1); }
/** * obtain miss count for a specific key * * @param key * timer key * @return hit count for a specific key */ public long getMissCount(String key) { TimeStats last = EVENT_MAP.get(key); return last != null ? last.getMissCount() : 0; }
/** * obtain miss elapsed time for a specific key in specified time units * * @param key * timer key * @param tunit * time unit * @return miss count for a specific key */ public long getMissAge(String key, TimeUnit tunit) { TimeStats last = EVENT_MAP.get(key); return last != null ? last.getMissAge(tunit): 0; }
/** * obtain hit elapsed time for a specific key in specified time units * * @param key * timer key * @param tunit * time unit * @return hit count for a specific key */ public long getHitAge(String key, TimeUnit tunit) { TimeStats last = EVENT_MAP.get(key); return last != null ? last.getHitAge(tunit): 0; }
/** * Hit and obtain elapsed nanoseconds since last hit based. Time statistics is maintained per thread. * * @return elapsed nanoseconds since last hit */ public static long hitAndGet() { return THREAD_TIMER.get().hit(); }
/** * Miss and obtain elapsed nanoseconds since last miss based. Time statistics is maintained per thread. * * @return elapsed nanoseconds since last miss */ public static long missAndGet() { return THREAD_TIMER.get().miss(); }