tmm1-perftools.rb 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/extconf.rb +1 -0
- data/ext/perftools.c +32 -24
- data/perftools.rb.gemspec +2 -2
- metadata +2 -2
data/ext/extconf.rb
CHANGED
data/ext/perftools.c
CHANGED
@@ -2,6 +2,26 @@
|
|
2
2
|
#include <node.h>
|
3
3
|
#include <env.h>
|
4
4
|
|
5
|
+
static VALUE Iallocate;
|
6
|
+
|
7
|
+
void
|
8
|
+
save_frame(struct FRAME *frame, void** result, int *depth)
|
9
|
+
{
|
10
|
+
VALUE klass = frame->last_class;
|
11
|
+
// XXX what is an ICLASS anyway?
|
12
|
+
// if (BUILTIN_TYPE(klass) == T_ICLASS)
|
13
|
+
// klass = RBASIC(klass)->klass;
|
14
|
+
|
15
|
+
if (FL_TEST(klass, FL_SINGLETON) &&
|
16
|
+
(BUILTIN_TYPE(frame->self) == T_CLASS || BUILTIN_TYPE(frame->self) == T_MODULE))
|
17
|
+
result[(*depth)++] = (void*) frame->self;
|
18
|
+
else
|
19
|
+
result[(*depth)++] = 0;
|
20
|
+
|
21
|
+
result[(*depth)++] = (void*) klass;
|
22
|
+
result[(*depth)++] = (void*) (frame->last_func == ID_ALLOCATOR ? Iallocate : frame->last_func);
|
23
|
+
}
|
24
|
+
|
5
25
|
int
|
6
26
|
rb_stack_trace(void** result, int max_depth)
|
7
27
|
{
|
@@ -9,30 +29,26 @@ rb_stack_trace(void** result, int max_depth)
|
|
9
29
|
struct FRAME *frame = ruby_frame;
|
10
30
|
NODE *n;
|
11
31
|
|
12
|
-
if (max_depth == 0)
|
32
|
+
if (max_depth == 0)
|
33
|
+
return 0;
|
34
|
+
|
35
|
+
// XXX: figure out what these mean. is there a way to access them from an extension?
|
13
36
|
// if (rb_prohibit_interrupt || !rb_trap_immediate) return 0;
|
14
37
|
|
38
|
+
#ifdef HAVE_RB_DURING_GC
|
15
39
|
if (rb_during_gc()) {
|
16
40
|
result[0] = rb_gc;
|
17
41
|
return 1;
|
18
42
|
}
|
43
|
+
#endif
|
19
44
|
|
45
|
+
// XXX does it make sense to track allocations or not?
|
20
46
|
if (frame->last_func == ID_ALLOCATOR) {
|
21
47
|
frame = frame->prev;
|
22
48
|
}
|
23
49
|
|
24
50
|
if (frame->last_func) {
|
25
|
-
|
26
|
-
// if (BUILTIN_TYPE(klass) == T_ICLASS)
|
27
|
-
// klass = RBASIC(klass)->klass;
|
28
|
-
|
29
|
-
if (FL_TEST(klass, FL_SINGLETON) && (BUILTIN_TYPE(frame->self) == T_CLASS || BUILTIN_TYPE(frame->self) == T_MODULE))
|
30
|
-
result[depth++] = (void*) frame->self;
|
31
|
-
else
|
32
|
-
result[depth++] = 0;
|
33
|
-
|
34
|
-
result[depth++] = (void*) klass;
|
35
|
-
result[depth++] = (void*) frame->last_func;
|
51
|
+
save_frame(frame, result, &depth);
|
36
52
|
}
|
37
53
|
|
38
54
|
for (; frame && (n = frame->node); frame = frame->prev) {
|
@@ -41,19 +57,10 @@ rb_stack_trace(void** result, int max_depth)
|
|
41
57
|
if (frame->prev->last_func == frame->last_func) continue;
|
42
58
|
}
|
43
59
|
|
44
|
-
if (depth+3 > max_depth)
|
45
|
-
|
46
|
-
VALUE klass = frame->prev->last_class;
|
47
|
-
// if (BUILTIN_TYPE(klass) == T_ICLASS)
|
48
|
-
// klass = RBASIC(klass)->klass;
|
49
|
-
|
50
|
-
if (FL_TEST(klass, FL_SINGLETON) && (BUILTIN_TYPE(frame->prev->self) == T_CLASS || BUILTIN_TYPE(frame->prev->self) == T_MODULE))
|
51
|
-
result[depth++] = (void*) frame->prev->self;
|
52
|
-
else
|
53
|
-
result[depth++] = 0;
|
60
|
+
if (depth+3 > max_depth)
|
61
|
+
break;
|
54
62
|
|
55
|
-
result
|
56
|
-
result[depth++] = (void*) frame->prev->last_func;
|
63
|
+
save_frame(frame->prev, result, &depth);
|
57
64
|
}
|
58
65
|
}
|
59
66
|
|
@@ -107,6 +114,7 @@ Init_perftools()
|
|
107
114
|
cPerfTools = rb_define_class("PerfTools", rb_cObject);
|
108
115
|
cCpuProfiler = rb_define_class_under(cPerfTools, "CpuProfiler", rb_cObject);
|
109
116
|
bProfilerRunning = Qfalse;
|
117
|
+
Iallocate = rb_intern("allocate");
|
110
118
|
|
111
119
|
rb_define_singleton_method(cCpuProfiler, "running?", cpuprofiler_running_p, 0);
|
112
120
|
rb_define_singleton_method(cCpuProfiler, "start", cpuprofiler_start, 1);
|
data/perftools.rb.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
spec = Gem::Specification.new do |s|
|
2
2
|
s.name = 'perftools.rb'
|
3
|
-
s.version = '0.1.
|
4
|
-
s.date = '2009-06-
|
3
|
+
s.version = '0.1.5'
|
4
|
+
s.date = '2009-06-02'
|
5
5
|
s.summary = 'google-perftools for ruby code'
|
6
6
|
s.description = 'A sampling profiler for ruby code based on patches to google-perftools'
|
7
7
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tmm1-perftools.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aman Gupta
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-02 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|