1The following are examples of js_cputime.d. 2 3This script traces the on-CPU time of JavaScript functions and prints a report. 4Here it traces the example program, Code/JavaScript/func_clock.html 5 6# js_cputime.d 7Tracing... Hit Ctrl-C to end. 8^C 9 10Count, 11 FILE TYPE NAME COUNT 12 func_clock.html func func_a 5 13 func_clock.html func func_b 5 14 func_clock.html func func_c 5 15 func_clock.html func setTimeout 5 16 func_clock.html func start 5 17 func_clock.html obj-new Date 5 18 func_clock.html func getElementById 20 19 - total - 50 20 21Elapsed times (us), 22 FILE TYPE NAME TOTAL 23 - total - 37 24 func_clock.html obj-new Date 37 25 26Exclusive function on-CPU times (us), 27 FILE TYPE NAME TOTAL 28 func_clock.html func setTimeout 316 29 func_clock.html func getElementById 588 30 func_clock.html func start 4734 31 func_clock.html func func_a 83465 32 func_clock.html func func_b 166613 33 func_clock.html func func_c 247683 34 - total - 503402 35 36Inclusive function on-CPU times (us), 37 FILE TYPE NAME TOTAL 38 func_clock.html func setTimeout 316 39 func_clock.html func getElementById 588 40 func_clock.html func func_c 247872 41 func_clock.html func func_b 414601 42 func_clock.html func func_a 498142 43 func_clock.html func start 503439 44 45You can see the results are printed in four sections. 46 47The first section reports how many times each subroutine was called, and it's 48type. 49 50The second section reports on the on-CPU time of anything that was not of type 51"func", in this case the only elements reported here are Date obj-new. 52 53The exclusive subroutine on-CPU times shows, amongst other results, that func_a 54spent around 83,000 microseconds on-CPU. This time excludes time spent in 55other subroutines. 56 57The inclusive subroutine on-CPU times show that func_a spent around 0.5 58seconds on-CPU. This includes the time spent in other subroutines 59called. 60 61These on-CPU times are the time the thread spent running on a CPU, from when 62the subroutine began to when it completed. This does not include time 63spent off-CPU time such as sleeping for I/O or waiting for scheduling. 64 65On-CPU times are useful for showing who is causing the CPUs to be busy. 66See Notes/ALLoncpu_notes.txt for more details. Also see 67Notes/ALLexclusive_notes.txt and Notes/ALLinclusive_notes.txt for a 68detailed explanation of exclusive vs inclusive subroutine time. 69 70