Is there a way to profile Javascript executed with Rhino? #1027
-
I am a user of Mirth Connect which uses Rhino to run Javascript. I had a use case the other day where my team needed to profile a dozen lines of Javascript. We accomplished this by simply adding logger statements before and after each line of code to capture timing data. Is there a better way to profile JS when running from Rhino? I did some searching and was able to find benchmarking code and discussion of profiling various JS engines. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
To my knowledge there isn't a stand-alone profiler implementation for Rhino, neither is there a standard for generic Profiler implementations (similar to the Debug Adapter Protocol for debugging) that allows you to plugin a runtime like Rhino into an IDE and be able to profile a runtime using a standardized Profiling UI. So, if you want a proper profiler, I think you'd have to create one yourself. The basic structure of an implementation would be something like: implement the org.mozilla.javascript.debug.Debugger interface and register it as debugger on your context using In your org.mozilla.javascript.debug.Debugger.getFrame() implementation you can then record whatever you want to record Of course there are many more details to it, but that is the basic gist of it |
Beta Was this translation helpful? Give feedback.
-
I've used JProfiler, that will show up compiled javascript classes. With some effort, you may find out where your performance bottleneck is. |
Beta Was this translation helpful? Give feedback.
To my knowledge there isn't a stand-alone profiler implementation for Rhino, neither is there a standard for generic Profiler implementations (similar to the Debug Adapter Protocol for debugging) that allows you to plugin a runtime like Rhino into an IDE and be able to profile a runtime using a standardized Profiling UI.
So, if you want a proper profiler, I think you'd have to create one yourself.
The basic structure of an implementation would be something like: implement the org.mozilla.javascript.debug.Debugger interface and register it as debugger on your context using
Context cx.setDebugger(...);
In your org.mozilla.javascript.debug.Debugger.getFrame() implementation you can then reco…