perftools.rb 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +4 -0
- data/ext/extconf.rb +1 -0
- data/ext/perftools.c +38 -1
- data/patches/perftools-objects.patch +5 -5
- data/patches/perftools-pprof.patch +2 -1
- data/perftools.rb.gemspec +2 -2
- metadata +4 -9
data/README
CHANGED
data/ext/extconf.rb
CHANGED
@@ -27,6 +27,7 @@ perftools = File.basename('google-perftools-1.4.tar.gz')
|
|
27
27
|
dir = File.basename(perftools, '.tar.gz')
|
28
28
|
|
29
29
|
puts "(I'm about to compile google-perftools.. this will definitely take a while)"
|
30
|
+
ENV["PATCH_GET"] = '0'
|
30
31
|
|
31
32
|
Dir.chdir('src') do
|
32
33
|
FileUtils.rm_rf(dir) if File.exists?(dir)
|
data/ext/perftools.c
CHANGED
@@ -213,6 +213,8 @@ static VALUE Isend;
|
|
213
213
|
|
214
214
|
static VALUE objprofiler_setup();
|
215
215
|
static VALUE objprofiler_teardown();
|
216
|
+
static VALUE methprofiler_setup();
|
217
|
+
static VALUE methprofiler_teardown();
|
216
218
|
|
217
219
|
/* CpuProfiler */
|
218
220
|
|
@@ -236,6 +238,7 @@ cpuprofiler_stop(VALUE self)
|
|
236
238
|
|
237
239
|
bProfilerRunning = Qfalse;
|
238
240
|
objprofiler_teardown();
|
241
|
+
methprofiler_teardown();
|
239
242
|
ProfilerStop();
|
240
243
|
ProfilerFlush();
|
241
244
|
|
@@ -252,6 +255,8 @@ cpuprofiler_start(VALUE self, VALUE filename)
|
|
252
255
|
|
253
256
|
if (getenv("CPUPROFILE_OBJECTS"))
|
254
257
|
objprofiler_setup();
|
258
|
+
else if (getenv("CPUPROFILE_METHODS"))
|
259
|
+
methprofiler_setup();
|
255
260
|
|
256
261
|
if (ProfilerStart(RSTRING_PTR(filename))) {
|
257
262
|
bProfilerRunning = Qtrue;
|
@@ -285,6 +290,7 @@ cpuprofiler_gc_mark()
|
|
285
290
|
#include <sys/mman.h>
|
286
291
|
|
287
292
|
static VALUE bObjProfilerRunning;
|
293
|
+
static VALUE bMethProfilerRunning;
|
288
294
|
#define NUM_ORIG_BYTES 2
|
289
295
|
|
290
296
|
struct {
|
@@ -332,6 +338,35 @@ uc_get_ip(ucontext_t *uc) {
|
|
332
338
|
return (char**)&uc->program_counter;
|
333
339
|
}
|
334
340
|
|
341
|
+
static void
|
342
|
+
event_handler(rb_event_t event, NODE *node, VALUE self, ID id, VALUE klass) {
|
343
|
+
ProfilerRecord(0, NULL, NULL);
|
344
|
+
}
|
345
|
+
|
346
|
+
static VALUE
|
347
|
+
methprofiler_setup()
|
348
|
+
{
|
349
|
+
if (bMethProfilerRunning)
|
350
|
+
return Qtrue;
|
351
|
+
|
352
|
+
rb_add_event_hook(event_handler, RUBY_EVENT_CALL);
|
353
|
+
|
354
|
+
bMethProfilerRunning = Qtrue;
|
355
|
+
return Qtrue;
|
356
|
+
}
|
357
|
+
|
358
|
+
static VALUE
|
359
|
+
methprofiler_teardown()
|
360
|
+
{
|
361
|
+
if (!bMethProfilerRunning)
|
362
|
+
return Qfalse;
|
363
|
+
|
364
|
+
rb_remove_event_hook(event_handler);
|
365
|
+
|
366
|
+
bMethProfilerRunning = Qfalse;
|
367
|
+
return Qtrue;
|
368
|
+
}
|
369
|
+
|
335
370
|
static void
|
336
371
|
trap_handler(int sig, siginfo_t *info, void *data) {
|
337
372
|
int i;
|
@@ -423,7 +458,7 @@ Init_perftools()
|
|
423
458
|
I__send__ = rb_intern("__send__");
|
424
459
|
Isend = rb_intern("send");
|
425
460
|
|
426
|
-
bObjProfilerRunning = bProfilerRunning = Qfalse;
|
461
|
+
bMethProfilerRunning = bObjProfilerRunning = bProfilerRunning = Qfalse;
|
427
462
|
|
428
463
|
rb_define_singleton_method(cCpuProfiler, "running?", cpuprofiler_running_p, 0);
|
429
464
|
rb_define_singleton_method(cCpuProfiler, "start", cpuprofiler_start, 1);
|
@@ -437,6 +472,8 @@ Init_perftools()
|
|
437
472
|
|
438
473
|
if (getenv("CPUPROFILE_OBJECTS")) { // want to profile objects
|
439
474
|
objprofiler_setup();
|
475
|
+
} else if (getenv("CPUPROFILE_METHODS")) {
|
476
|
+
methprofiler_setup();
|
440
477
|
}
|
441
478
|
|
442
479
|
rb_set_end_proc(profiler_at_exit, 0); // make sure to cleanup before the VM shuts down
|
@@ -12,7 +12,7 @@ index 619b980..2ecf2c0 100644
|
|
12
12
|
}
|
13
13
|
|
14
14
|
void ProfileHandler::StartTimer() {
|
15
|
-
+ if (getenv("CPUPROFILE_OBJECTS")) return;
|
15
|
+
+ if (getenv("CPUPROFILE_OBJECTS") || getenv("CPUPROFILE_METHODS")) return;
|
16
16
|
+
|
17
17
|
struct itimerval timer;
|
18
18
|
timer.it_interval.tv_sec = 0;
|
@@ -21,7 +21,7 @@ index 619b980..2ecf2c0 100644
|
|
21
21
|
}
|
22
22
|
|
23
23
|
void ProfileHandler::StopTimer() {
|
24
|
-
+ if (getenv("CPUPROFILE_OBJECTS")) return;
|
24
|
+
+ if (getenv("CPUPROFILE_OBJECTS") || getenv("CPUPROFILE_METHODS")) return;
|
25
25
|
+
|
26
26
|
struct itimerval timer;
|
27
27
|
memset(&timer, 0, sizeof timer);
|
@@ -29,7 +29,7 @@ index 619b980..2ecf2c0 100644
|
|
29
29
|
}
|
30
30
|
|
31
31
|
bool ProfileHandler::IsTimerRunning() {
|
32
|
-
+ if (getenv("CPUPROFILE_OBJECTS")) return false;
|
32
|
+
+ if (getenv("CPUPROFILE_OBJECTS") || getenv("CPUPROFILE_METHODS")) return false;
|
33
33
|
+
|
34
34
|
struct itimerval current_timer;
|
35
35
|
RAW_CHECK(0 == getitimer(realtime_ ? ITIMER_REAL : ITIMER_PROF, ¤t_timer), "getitimer");
|
@@ -38,7 +38,7 @@ index 619b980..2ecf2c0 100644
|
|
38
38
|
}
|
39
39
|
|
40
40
|
void ProfileHandler::EnableHandler() {
|
41
|
-
+ if (getenv("CPUPROFILE_OBJECTS")) return;
|
41
|
+
+ if (getenv("CPUPROFILE_OBJECTS") || getenv("CPUPROFILE_METHODS")) return;
|
42
42
|
+
|
43
43
|
struct sigaction sa;
|
44
44
|
sa.sa_sigaction = SignalHandler;
|
@@ -47,7 +47,7 @@ index 619b980..2ecf2c0 100644
|
|
47
47
|
}
|
48
48
|
|
49
49
|
void ProfileHandler::DisableHandler() {
|
50
|
-
+ if (getenv("CPUPROFILE_OBJECTS")) return;
|
50
|
+
+ if (getenv("CPUPROFILE_OBJECTS") || getenv("CPUPROFILE_METHODS")) return;
|
51
51
|
+
|
52
52
|
struct sigaction sa;
|
53
53
|
sa.sa_handler = SIG_IGN;
|
@@ -30,13 +30,14 @@ index b5ef29a..25b956d 100755
|
|
30
30
|
# Remove uniniteresting stack items
|
31
31
|
$profile = RemoveUninterestingFrames($symbols, $profile);
|
32
32
|
|
33
|
-
@@ -1927,6 +1927,
|
33
|
+
@@ -1927,6 +1927,10 @@ sub RemoveUninterestingFrames {
|
34
34
|
'ProfileData::prof_handler', # historical
|
35
35
|
'CpuProfiler::prof_handler',
|
36
36
|
'__FRAME_END__',
|
37
37
|
+ 'PerfTools::CpuProfiler.start',
|
38
38
|
+ 'Array#each',
|
39
39
|
+ 'Proc#call',
|
40
|
+
+ 'Class#new',
|
40
41
|
'__pthread_sighandler',
|
41
42
|
'__restore') {
|
42
43
|
$skip{$name} = 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.5.
|
4
|
-
s.date = '2010-
|
3
|
+
s.version = '0.5.1'
|
4
|
+
s.date = '2010-11-12'
|
5
5
|
s.rubyforge_project = 'perftools-rb'
|
6
6
|
s.summary = 'google-perftools for ruby code'
|
7
7
|
s.description = 'A sampling profiler for ruby code based on patches to google-perftools'
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: perftools.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 11
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
8
|
+
- 1
|
9
|
+
version: 0.5.1
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Aman Gupta
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-
|
17
|
+
date: 2010-11-12 00:00:00 -06:00
|
19
18
|
default_executable:
|
20
19
|
dependencies: []
|
21
20
|
|
@@ -55,27 +54,23 @@ rdoc_options: []
|
|
55
54
|
require_paths:
|
56
55
|
- lib
|
57
56
|
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
57
|
requirements:
|
60
58
|
- - ">="
|
61
59
|
- !ruby/object:Gem::Version
|
62
|
-
hash: 3
|
63
60
|
segments:
|
64
61
|
- 0
|
65
62
|
version: "0"
|
66
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
-
none: false
|
68
64
|
requirements:
|
69
65
|
- - ">="
|
70
66
|
- !ruby/object:Gem::Version
|
71
|
-
hash: 3
|
72
67
|
segments:
|
73
68
|
- 0
|
74
69
|
version: "0"
|
75
70
|
requirements: []
|
76
71
|
|
77
72
|
rubyforge_project: perftools-rb
|
78
|
-
rubygems_version: 1.3.
|
73
|
+
rubygems_version: 1.3.6
|
79
74
|
signing_key:
|
80
75
|
specification_version: 3
|
81
76
|
summary: google-perftools for ruby code
|