1*c29d5175SchristosThe following are examples of php_cputime.d. 2*c29d5175Schristos 3*c29d5175SchristosThis script traces the on-CPU time of PHP functions and prints a report. 4*c29d5175SchristosHere it traces the example program, Code/Php/func_abc.php. 5*c29d5175Schristos 6*c29d5175Schristos# php_cputime.d 7*c29d5175SchristosTracing... Hit Ctrl-C to end. 8*c29d5175Schristos^C 9*c29d5175Schristos 10*c29d5175SchristosCount, 11*c29d5175Schristos FILE TYPE NAME COUNT 12*c29d5175Schristos func_abc.php func func_a 1 13*c29d5175Schristos func_abc.php func func_b 1 14*c29d5175Schristos func_abc.php func func_c 1 15*c29d5175Schristos func_abc.php func sleep 3 16*c29d5175Schristos - total - 6 17*c29d5175Schristos 18*c29d5175SchristosExclusive function on-CPU times (us), 19*c29d5175Schristos FILE TYPE NAME TOTAL 20*c29d5175Schristos func_abc.php func func_c 17 21*c29d5175Schristos func_abc.php func func_b 25 22*c29d5175Schristos func_abc.php func func_a 74 23*c29d5175Schristos func_abc.php func sleep 93 24*c29d5175Schristos - total - 210 25*c29d5175Schristos 26*c29d5175SchristosInclusive function on-CPU times (us), 27*c29d5175Schristos FILE TYPE NAME TOTAL 28*c29d5175Schristos func_abc.php func func_c 39 29*c29d5175Schristos func_abc.php func func_b 87 30*c29d5175Schristos func_abc.php func sleep 93 31*c29d5175Schristos func_abc.php func func_a 210 32*c29d5175Schristos 33*c29d5175SchristosIn total, six functions were called; sleep was called three times and there 34*c29d5175Schristoswas one call each of func_a(), func_b() and func_c(). 35*c29d5175Schristos 36*c29d5175SchristosThe exclusive subroutine on-CPU times show that func_a() spent around 74 37*c29d5175Schristosmicroseconds on-CPU, func_b() spent 25 microseconds on-CPU, and func_c() spent 38*c29d5175Schristos17 microseconds on-CPU. This exclusive times excludes time spent in other 39*c29d5175Schristossubroutines. 40*c29d5175Schristos 41*c29d5175SchristosThe inclusive subroutine on-CPU times show that func_c() spent around 39 42*c29d5175Schristosmicroseconds on-CPU, func_b() spent around 87 microseconds on-CPU and 43*c29d5175Schristosfunc_a() spent around 210 microseconds. This inclusive time includes the time 44*c29d5175Schristosspent in other functions called (including sleep), and since func_a() called 45*c29d5175Schristosfunc_b() which called func_c(), these times make perfect sense. 46*c29d5175Schristos 47*c29d5175SchristosThese on-CPU times are the time the program spent running on a CPU, from when 48*c29d5175Schristosthe function began to when it completed. This does not include time 49*c29d5175Schristosspent off-CPU time such as sleeping for I/O or waiting for scheduling. 50*c29d5175Schristos 51*c29d5175SchristosOn-CPU times are useful for showing who is causing the CPUs to be busy. 52*c29d5175SchristosSee Notes/ALLoncpu_notes.txt for more details. Also see 53*c29d5175SchristosNotes/ALLexclusive_notes.txt and Notes/ALLinclusive_notes.txt for a 54*c29d5175Schristosdetailed explanation of exclusive vs inclusive subroutine time. 55*c29d5175Schristos 56*c29d5175SchristosIf you study the func_abc.php program alongside the above output, the numbers 57*c29d5175Schristosshould make sense. 58*c29d5175Schristos 59