Improved profiler logs
This commit is contained in:
parent
29fcc5539d
commit
9759f468fe
1 changed files with 8 additions and 7 deletions
|
@ -8,9 +8,9 @@ public class LocalProfiler {
|
||||||
public long internal;
|
public long internal;
|
||||||
public String name;
|
public String name;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Stack<StackElement> stack = new Stack<StackElement>();
|
private static Stack<StackElement> stack = new Stack<StackElement>();
|
||||||
|
|
||||||
public static void start(String name) {
|
public static void start(String name) {
|
||||||
StackElement stackElement = new StackElement();
|
StackElement stackElement = new StackElement();
|
||||||
stackElement.start = System.nanoTime();
|
stackElement.start = System.nanoTime();
|
||||||
|
@ -18,12 +18,12 @@ public class LocalProfiler {
|
||||||
stackElement.name = name;
|
stackElement.name = name;
|
||||||
stack.push(stackElement);
|
stack.push(stackElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void stop() {
|
public static void stop() {
|
||||||
if (stack.isEmpty()) {
|
if (stack.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
StackElement stackElement = stack.pop();
|
StackElement stackElement = stack.pop();
|
||||||
long end = System.nanoTime();
|
long end = System.nanoTime();
|
||||||
long dt = end - stackElement.start;
|
long dt = end - stackElement.start;
|
||||||
|
@ -32,9 +32,10 @@ public class LocalProfiler {
|
||||||
StackElement nextStackElement = stack.peek();
|
StackElement nextStackElement = stack.peek();
|
||||||
nextStackElement.internal += dt;
|
nextStackElement.internal += dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
long self = (dt - stackElement.internal) / 1000; // in microseconds
|
// convert to microseconds
|
||||||
|
long self = (dt - stackElement.internal) / 1000;
|
||||||
long total = dt / 1000;
|
long total = dt / 1000;
|
||||||
WarpDrive.logger.info("Profiling '" + stackElement.name + "': " + (self / 1000.0F) + " ms, total: " + (total / 1000.0F) + " ms");
|
WarpDrive.logger.info("Profiling " + stackElement.name + ": " + (self / 1000.0F) + " ms" + ((total == self) ? "" : (", total: " + (total / 1000.0F) + " ms")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue