]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - cddl/contrib/dtracetoolkit/Ruby/rb_objcpu.d
MFC r368207,368607:
[FreeBSD/stable/10.git] / cddl / contrib / dtracetoolkit / Ruby / rb_objcpu.d
1 #!/usr/sbin/dtrace -Zs
2 /*
3  * rb_objcpu.d - measure Ruby object creation on-CPU time using DTrace.
4  *               Written for the Ruby DTrace provider.
5  *
6  * $Id: rb_objcpu.d 20 2007-09-12 09:28:22Z brendan $
7  *
8  * This traces Ruby activity from all programs running on the system with
9  * Ruby provider support.
10  *
11  * USAGE: rb_objcpu.d           # hit Ctrl-C to end
12  *
13  * Class names are printed if available.
14  *
15  * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
16  *
17  * CDDL HEADER START
18  *
19  *  The contents of this file are subject to the terms of the
20  *  Common Development and Distribution License, Version 1.0 only
21  *  (the "License").  You may not use this file except in compliance
22  *  with the License.
23  *
24  *  You can obtain a copy of the license at Docs/cddl1.txt
25  *  or http://www.opensolaris.org/os/licensing.
26  *  See the License for the specific language governing permissions
27  *  and limitations under the License.
28  *
29  * CDDL HEADER END
30  *
31  * 09-Sep-2007  Brendan Gregg   Created this.
32  */
33
34 #pragma D option quiet
35
36 dtrace:::BEGIN
37 {
38         printf("Tracing... Hit Ctrl-C to end.\n");
39 }
40
41 ruby*:::object-create-start
42 {
43         self->vstart = vtimestamp;
44 }
45
46 ruby*:::object-create-done
47 /self->vstart/
48 {
49         this->oncpu = vtimestamp - self->vstart;
50         @total = sum(this->oncpu);
51         @dist[copyinstr(arg0)] = quantize(this->oncpu / 1000);
52         self->vstart = 0;
53 }
54
55 dtrace:::END
56 {
57         normalize(@total, 1000000);
58         printa("Total object creation on-CPU time (ms): %@d\n\n", @total);
59         printf("Object creation on-CPU time distributions (us),\n");
60         printa(@dist);
61 }