xref: /netbsd-src/external/cddl/dtracetoolkit/dist/Examples/php_cputime_example.txt (revision c29d51755812ace2e87aeefdb06cb2b4dac7087a)
1The following are examples of php_cputime.d.
2
3This script traces the on-CPU time of PHP functions and prints a report.
4Here it traces the example program, Code/Php/func_abc.php.
5
6# php_cputime.d
7Tracing... Hit Ctrl-C to end.
8^C
9
10Count,
11   FILE                 TYPE       NAME                                COUNT
12   func_abc.php         func       func_a                                  1
13   func_abc.php         func       func_b                                  1
14   func_abc.php         func       func_c                                  1
15   func_abc.php         func       sleep                                   3
16   -                    total      -                                       6
17
18Exclusive function on-CPU times (us),
19   FILE                 TYPE       NAME                                TOTAL
20   func_abc.php         func       func_c                                 17
21   func_abc.php         func       func_b                                 25
22   func_abc.php         func       func_a                                 74
23   func_abc.php         func       sleep                                  93
24   -                    total      -                                     210
25
26Inclusive function on-CPU times (us),
27   FILE                 TYPE       NAME                                TOTAL
28   func_abc.php         func       func_c                                 39
29   func_abc.php         func       func_b                                 87
30   func_abc.php         func       sleep                                  93
31   func_abc.php         func       func_a                                210
32
33In total, six functions were called; sleep was called three times and there
34was one call each of func_a(), func_b() and func_c().
35
36The exclusive subroutine on-CPU times show that func_a() spent around 74
37microseconds on-CPU, func_b() spent 25 microseconds on-CPU, and func_c() spent
3817 microseconds on-CPU. This exclusive times excludes time spent in other
39subroutines.
40
41The inclusive subroutine on-CPU times show that func_c() spent around 39
42microseconds on-CPU, func_b() spent around 87 microseconds on-CPU and
43func_a() spent around 210 microseconds. This inclusive time includes the time
44spent in other functions called (including sleep),  and since func_a() called
45func_b() which called func_c(), these times make perfect sense.
46
47These on-CPU times are the time the program spent running on a CPU, from when
48the function began to when it completed. This does not include time
49spent off-CPU time such as sleeping for I/O or waiting for scheduling.
50
51On-CPU times are useful for showing who is causing the CPUs to be busy.
52See Notes/ALLoncpu_notes.txt for more details. Also see
53Notes/ALLexclusive_notes.txt and Notes/ALLinclusive_notes.txt for a
54detailed explanation of exclusive vs inclusive subroutine time.
55
56If you study the func_abc.php program alongside the above output, the numbers
57should make sense.
58
59