Java Reference
In-Depth Information
When the debugger finishes, you can remove the breakpoints from the Java code
that is the PrimaTest.java file in this example. If you start a new debugging session, the
debugger will stop at the breakpoints you had set in the <eval>.js file previously. Notice
that you had to step into the <eval>.js file only once. All subsequent debugging sessions
remember the breakpoints from the previous sessions.
even though the debugger statement is supported by nashorn, the netbeans iDe
does not seem to recognize it as a breakpoint in nashorn scripts. adding the debugger
statement in scripts does not suspend the execution when the debugger is active.
Tip
Tracing and Profiling Scripts
Nashorn supports callsite tracing and profiling. You can enable these options in the jjs
command-line tool as well as in the embedded Nashorn engine. You can enable tracing
and profiling for all scripts run by the engine or per script/function. The -tcs option
enables callsite tracing for all scripts and prints the callsite tracing information on the
standard output. The -pcs option enables callsite profiling for all scripts and prints the
callsite profiling data in a file called NashornProfile.txt in the current directory.
You can use the following four Nashorn directives in the beginning of scripts or
functions to selectively trace and profile the entire script or functions:
"nashorn callsite trace enterexit";
// Equivalent to -tcs=enterexit
"nashorn callsite trace miss";
// Equivalent to -tcs=miss
"nashorn callsite trace objects";
// Equivalent to -tcs=objects
"nashorn callsite profile";
// Equivalent to -pcs
the -tcs and -pcs options work on per script engine basis, whereas the four
tracing and profiling directives work on per script and per function basis.
Tip
These Nashorn directives are enabled only in debug mode. You can enable Nashorn
debug mode by setting the nashorn.debug system property to true. These directive are
available in JDK8u40 and later. JDK8u40 is still in development at the time of writing of
this topic. Listing 13-3 shows a script with a Nashorn callsite profile option enabled for a
function. The script has been saved in the file named primeprofiler.js .
 
 
Search WWH ::




Custom Search