Some obvious profiler fixes

This commit is contained in:
hns 2009-09-28 12:55:24 +00:00
parent 7483b7a8ad
commit 3cef3759a8
2 changed files with 10 additions and 8 deletions

View file

@ -216,8 +216,11 @@ public class RhinoEngine implements ScriptingEngine {
try { try {
Profiler profiler = (Profiler) Context.getCurrentContext().getDebugger(); Profiler profiler = (Profiler) Context.getCurrentContext().getDebugger();
String result = profiler.getResult(); String result = profiler.getResult();
getResponse().debug("<pre>" + result + "</pre>"); ResponseTrans res = getResponse();
System.out.println(result); if (res != null) {
getResponse().debug("<pre>" + result + "</pre>");
}
app.logEvent(result);
} catch (Exception x) { } catch (Exception x) {
app.logError("Error in profiler: " + x, x); app.logError("Error in profiler: " + x, x);
} }

View file

@ -46,11 +46,12 @@ public class Profiler implements Debugger {
*/ */
static String getFunctionName(DebuggableScript script) { static String getFunctionName(DebuggableScript script) {
if (script.isFunction()) { if (script.isFunction()) {
StringBuffer b = new StringBuffer(script.getSourceName()).append(" #");
b.append(script.getLineNumbers()[0]);
if (script.getFunctionName() != null) { if (script.getFunctionName() != null) {
return script.getSourceName() + ": " + script.getFunctionName(); b.append(": ").append(script.getFunctionName());
} else {
return script.getSourceName() + ": #" + script.getLineNumbers()[0];
} }
return b.toString();
} else { } else {
return script.getSourceName(); return script.getSourceName();
} }
@ -96,9 +97,7 @@ public class Profiler implements Debugger {
* Called when thrown exception is handled by the function or script. * Called when thrown exception is handled by the function or script.
*/ */
public void onExceptionThrown(Context cx, Throwable ex) { public void onExceptionThrown(Context cx, Throwable ex) {
invocations ++; // TODO: figure out if this is called in addition or in place of to onExit
Long time = (Long) timer.pop();
runtime += System.nanoTime() - time.longValue();
} }
/** /**