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