1 The following is an example of running rb_calldist.d and tracing the elapsed
4 We run rb_calldist.d while running the program Code/Ruby/func_abc.rb. We can
5 see that there are three sections in the DTrace output
8 Tracing... Hit Ctrl-C to end.
12 ., obj-new, NoMemoryError
13 value ------------- Distribution ------------- count
15 2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
18 ., obj-new, SystemStackError
19 value ------------- Distribution ------------- count
21 2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
24 ., obj-new, ThreadGroup
25 value ------------- Distribution ------------- count
27 8 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
31 value ------------- Distribution ------------- count
33 8 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
37 value ------------- Distribution ------------- count
39 2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2
46 Exclusive function elapsed times (us),
47 func_abc.rb, func, Module::method_added
48 value ------------- Distribution ------------- count
50 2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2
54 func_abc.rb, func, Object::print
55 value ------------- Distribution ------------- count
57 16 |@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2
61 func_abc.rb, func, IO::write
62 value ------------- Distribution ------------- count
64 32 |@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2
68 func_abc.rb, func, Object::func_a
69 value ------------- Distribution ------------- count
71 256 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
74 func_abc.rb, func, Object::func_b
75 value ------------- Distribution ------------- count
77 256 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
80 func_abc.rb, func, Object::func_c
81 value ------------- Distribution ------------- count
83 256 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
86 func_abc.rb, func, Object::sleep
87 value ------------- Distribution ------------- count
89 524288 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 3
93 Inclusive function elapsed times (us),
94 func_abc.rb, func, Module::method_added
95 value ------------- Distribution ------------- count
97 2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2
101 func_abc.rb, func, IO::write
102 value ------------- Distribution ------------- count
104 32 |@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2
108 func_abc.rb, func, Object::print
109 value ------------- Distribution ------------- count
111 64 |@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2
115 func_abc.rb, func, Object::func_c
116 value ------------- Distribution ------------- count
118 524288 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
121 func_abc.rb, func, Object::func_b
122 value ------------- Distribution ------------- count
124 1048576 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
127 func_abc.rb, func, Object::sleep
128 value ------------- Distribution ------------- count
130 524288 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 3
133 func_abc.rb, func, Object::func_a
134 value ------------- Distribution ------------- count
136 2097152 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
139 The elapsed times show us that the script spent some small amount of time
140 processing various events that were not functions. In this case they were all
141 obj-new events, and you can see that the slowest of these was a new Object at
142 between 16 microseconds and 31 microseconds.
144 The exclusive subroutine elapsed times show that each of our user defined
145 functions took between 256 and 511 microseconds. This time excludes the time
146 spent in other subroutines.
148 The inclusive subroutine elapsed times show that func_c() took between 0.5
149 seconds and 1 second, func_b() took between 1 second and 2.1 seconds, and
150 func_a() took between 2.1 seconds and 4.2 seconds to execute. This time
151 includes the time spent in other subroutines called, and since func_a() called
152 func_b() which called func_c(), these times make sense.