mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-20 02:05:58 +10:00
[유치수] [NOBTS] add mysql interceptor
git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@556 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package com.profiler;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.profiler.util.NamedThreadLocal;
|
||||
|
||||
public class StopWatch {
|
||||
|
||||
private static ThreadLocal<Map<String, Long>> local = new NamedThreadLocal<Map<String, Long>>("StopWatch");
|
||||
|
||||
public static void start(String name) {
|
||||
Map<String, Long> map = local.get();
|
||||
if (map == null) {
|
||||
map = new HashMap<String, Long>(1);
|
||||
map.put(name, System.currentTimeMillis());
|
||||
local.set(map);
|
||||
} else {
|
||||
map.put(name, System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
public static long stopAndGetElapsed(String name) {
|
||||
Map<String, Long> map = local.get();
|
||||
if (map == null) {
|
||||
throw new IllegalStateException("Stopwatch is not started.");
|
||||
} else {
|
||||
return System.currentTimeMillis() - map.get(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user