提交 cca8464f authored 作者: Thomas Mueller Graf's avatar Thomas Mueller Graf

Profiler: support for method-level summaries

上级 c7289919
...@@ -37,6 +37,7 @@ public class Profiler implements Runnable { ...@@ -37,6 +37,7 @@ public class Profiler implements Runnable {
public int depth = 48; public int depth = 48;
public boolean paused; public boolean paused;
public boolean sumClasses; public boolean sumClasses;
public boolean sumMethods;
private int pid; private int pid;
...@@ -149,7 +150,21 @@ public class Profiler implements Runnable { ...@@ -149,7 +150,21 @@ public class Profiler implements Runnable {
} }
} }
try { try {
for (String file : args) { for (String arg : args) {
if (arg.startsWith("-")) {
if ("-classes".equals(arg)) {
sumClasses = true;
} else if ("-methods".equals(arg)) {
sumMethods = true;
} else if ("-packages".equals(args)) {
sumClasses = false;
sumMethods = false;
} else {
throw new IllegalArgumentException(arg);
}
continue;
}
String file = arg;
Reader reader; Reader reader;
LineNumberReader r; LineNumberReader r;
reader = new InputStreamReader( reader = new InputStreamReader(
...@@ -170,7 +185,7 @@ public class Profiler implements Runnable { ...@@ -170,7 +185,7 @@ public class Profiler implements Runnable {
processList(readStackTrace(r)); processList(readStackTrace(r));
reader.close(); reader.close();
} }
System.out.println(getTopTraces(3)); System.out.println(getTopTraces(5));
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
...@@ -383,6 +398,10 @@ public class Profiler implements Runnable { ...@@ -383,6 +398,10 @@ public class Profiler implements Runnable {
int m = el.indexOf('.', index + 1); int m = el.indexOf('.', index + 1);
index = m >= 0 ? m : index; index = m >= 0 ? m : index;
} }
if (sumMethods) {
int m = el.indexOf('(', index + 1);
index = m >= 0 ? m : index;
}
String groupName = el.substring(0, index); String groupName = el.substring(0, index);
increment(summary, groupName, 0); increment(summary, groupName, 0);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论