On Tue, Oct 27, 2009 at 06:06:44PM +0000, Joel Reymont
wrote:>
> On Oct 27, 2009, at 6:03 PM, Jonathan Adams wrote:
>
> >Clear clears all values in the aggregation to 0; to remove all
> >elements from
> >the aggregation, you want trunc(@a).
>
> That''s what I wanted to say but doesn''t printa(@a) come
before the
> clear?
Your original script, as a #! script:
--- cut here ---
#!/usr/sbin/dtrace -s
hotspot27563:::
{
/* every time a probe is hit, record it in the aggregation under name */
@[probename]=count();
}
profile:::tick-1sec
{
printa(@); /* print the current contents of @ */
clear(@); /* clear the counts in @ to 0 */
}
--- cut here ---
Without the clear(), you would just print the running counts every second.
With the clear(), you print the running counts, then clear them to zero
*without removing the aggregation entries*.
With s/clear/trunc/g, you would *remove all aggregation entries* from @.
Since I don''t have a java process handy, I''ll demonstrate
using the proc:::
provider:
% dtrace -n''proc:::{@[probename]=count()}''
-n''tick-1s{printa(@);}''
dtrace: description ''proc:::'' matched 15 probes
dtrace: description ''tick-1s'' matched 1 probe
CPU ID FUNCTION:NAME
0 66088 :tick-1s
signal-send 30
signal-handle 31
...
0 66088 :tick-1s
signal-handle 97
signal-send 131
0 66088 :tick-1s
exit 2
lwp-exit 2
create 3
lwp-create 3
lwp-start 3
signal-discard 3
start 3
exec 4
exec-success 4
signal-handle 121
signal-send 162
0 66088 :tick-1s
signal-discard 5
exit 10
lwp-exit 10
create 11
exec 11
exec-success 11
lwp-create 11
lwp-start 11
start 11
signal-handle 158
signal-send 203
0 66088 :tick-1s
signal-discard 5
exit 10
lwp-exit 10
exec-success 11
create 13
exec 13
lwp-create 13
lwp-start 13
start 13
signal-handle 176
signal-send 252
...
0 66088 :tick-1s
signal-discard 5
exec 18
exec-success 18
exit 18
lwp-exit 18
create 19
lwp-create 19
lwp-start 19
start 19
signal-handle 299
signal-send 399
^C
With clear(), this would look like:
% dtrace -n''proc:::{@[probename]=count()}''
-n''tick-1s{printa(@);clear(@)}''
dtrace: description ''proc:::'' matched 15 probes
dtrace: description ''tick-1s'' matched 1 probe
CPU ID FUNCTION:NAME
0 66088 :tick-1s
signal-send 30
signal-handle 31
...
0 66088 :tick-1s
signal-handle 67
signal-send 100
0 66088 :tick-1s
exit 2
lwp-exit 2
create 3
lwp-create 3
lwp-start 3
signal-discard 3
start 3
exec 4
exec-success 4
signal-handle 24
signal-send 31
0 66088 :tick-1s
exit 2
signal-discard 2
exec 7
exec-success 7
create 8
lwp-create 8
lwp-exit 8
lwp-start 8
start 8
signal-handle 37
signal-send 41
0 66088 :tick-1s
signal-discard 0
exit 0
lwp-exit 0
exec-success 0
create 2
exec 2
lwp-create 2
lwp-start 2
start 2
signal-handle 18
signal-send 49
...
0 66088 :tick-1s
signal-discard 0
exec 0
exec-success 0
exit 0
lwp-exit 0
create 0
lwp-create 0
lwp-start 0
start 0
signal-handle 5
signal-send 6
^C
With trunc(), this looks like:
% dtrace -n''proc:::{@[probename]=count()}''
-n''tick-1s{printa(@);trunc(@)}''
dtrace: description ''proc:::'' matched 15 probes
dtrace: description ''tick-1s'' matched 1 probe
CPU ID FUNCTION:NAME
0 66088 :tick-1s
signal-send 30
signal-handle 31
...
0 66088 :tick-1s
signal-handle 67
signal-send 100
0 66088 :tick-1s
exit 2
lwp-exit 2
create 3
lwp-create 3
lwp-start 3
signal-discard 3
start 3
exec 4
exec-success 4
signal-handle 24
signal-send 31
0 66088 :tick-1s
exit 2
signal-discard 2
exec 7
exec-success 7
create 8
lwp-create 8
lwp-exit 8
lwp-start 8
start 8
signal-handle 37
signal-send 41
0 66088 :tick-1s
create 2
exec 2
lwp-create 2
lwp-start 2
start 2
signal-handle 18
signal-send 49
...
0 66088 :tick-1s
signal-handle 5
signal-send 6
^C
Is that clear?
Cheers,
- jonathan
>
> ---
> firefox for android!
> http://wagerlabs.com