The following are examples of js_cputime.d.
This script traces the on-CPU time of JavaScript functions and prints a report.
Here it traces the example program, Code/JavaScript/func_clock.html
Tracing... Hit Ctrl-C to end.
^C
Count,
FILE TYPE NAME COUNT
func_clock.html func func_a 5
func_clock.html func func_b 5
func_clock.html func func_c 5
func_clock.html func setTimeout 5
func_clock.html func start 5
func_clock.html obj-new Date 5
func_clock.html func getElementById 20
- total - 50
Elapsed times (us),
FILE TYPE NAME TOTAL
- total - 37
func_clock.html obj-new Date 37
Exclusive function on-CPU times (us),
FILE TYPE NAME TOTAL
func_clock.html func setTimeout 316
func_clock.html func getElementById 588
func_clock.html func start 4734
func_clock.html func func_a 83465
func_clock.html func func_b 166613
func_clock.html func func_c 247683
- total - 503402
Inclusive function on-CPU times (us),
FILE TYPE NAME TOTAL
func_clock.html func setTimeout 316
func_clock.html func getElementById 588
func_clock.html func func_c 247872
func_clock.html func func_b 414601
func_clock.html func func_a 498142
func_clock.html func start 503439
You can see the results are printed in four sections.
The first section reports how many times each subroutine was called, and it's
type.
The second section reports on the on-CPU time of anything that was not of type
"func", in this case the only elements reported here are Date obj-new.
The exclusive subroutine on-CPU times shows, amongst other results, that func_a
spent around 83,000 microseconds on-CPU. This time excludes time spent in
other subroutines.
The inclusive subroutine on-CPU times show that func_a spent around 0.5
seconds on-CPU. This includes the time spent in other subroutines
called.
These on-CPU times are the time the thread spent running on a CPU, from when
the subroutine began to when it completed. This does not include time
spent off-CPU time such as sleeping for I/O or waiting for scheduling.
On-CPU times are useful for showing who is causing the CPUs to be busy.
See Notes/ALLoncpu_notes.txt for more details. Also see
detailed explanation of exclusive vs inclusive subroutine time.