/** * 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); }
/** * 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(); }
/** * 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(); }
/** * 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(); }