[유치수] [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:
Chisu Yu
2012-08-29 06:04:59 +00:00
parent c703ac84c9
commit 34dd7ef06d
8 changed files with 203 additions and 106 deletions
+31
View File
@@ -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);
}
}
}