...
| Code Block |
|---|
|
jjs> var name = readLine("What is your name? ")
What is your name? Bob
jjs> print("Hello, ${name}!")
Hello, Bob!
jjs>
|
| Anchor |
|---|
| callsite_tracing |
|---|
| callsite_tracing |
|---|
|
Nashorn call site tracing and profiling
Nashorn supports callsite tracing and profile jjs (jjs tool) options via command line options -tcs and -pcs. You can pass these to jjs tool or set these options via "nashorn.args" System property. But these options produce trace, profile output for all scripts that are run. To avoid having to look at too many trace outputs (or too big NashornProfile.txt file to scan!), nashorn allows per script or per function tracing, profiling via directives.
You can include nashorn specific user directives ( directive prologues ) at the start of a source script or at the start of a script function as shown below:
| Code Block |
|---|
| title | tracing, profiling directives |
|---|
|
function func() {
"nashorn callsite trace enterexit"; // equivalent to -tcs=enterexit
"nashorn callsite trace miss"; // equivalent to -tcs=miss
"nashorn callsite trace objects"; // equivalent to -tcs=objects
print("hello");
}
func(); |
| Code Block |
|---|
|
function func() {
"nashorn callsite profile"; // equivalent to -pcs
for(var i = 0; i < 10; i++) print("hello " + i);
}
func(); |
Just like -pcs option, profile directive will produce NashornProfile.txt file in the current dir of the application. But
profiling is enabled per script or per function only rather than globally.