Created
November 19, 2012 20:25
-
-
Save jamesgolick/4113649 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static VALUE | |
gc_basic_profile_total_time(VALUE self) | |
{ | |
rb_objspace_t *objspace = &rb_objspace; | |
return DBL2NUM(objspace->basic_profile.total_time); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef struct gc_profile_record { | |
double gc_time; | |
double gc_mark_time; | |
double gc_sweep_time; | |
double gc_invoke_time; | |
size_t heap_use_slots; | |
size_t heap_live_objects; | |
size_t heap_free_objects; | |
size_t heap_total_objects; | |
size_t heap_use_size; | |
size_t heap_total_size; | |
int have_finalize; | |
int is_marked; | |
size_t allocate_increase; | |
size_t allocate_limit; | |
} gc_profile_record; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(gdb) p ruby_current_vm->objspace->profile.count | |
$1 = 533282 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.9.3p194 :001 > GC::Profiler.enabled? | |
=> false | |
1.9.3p194 :002 > GC::Profiler.enable | |
=> nil | |
1.9.3p194 :003 > GC::Profiler.enabled? | |
=> 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Total: 90 samples | |
49 54.4% 54.4% 49 54.4% GC::Profiler.total_time | |
9 10.0% 64.4% 9 10.0% garbage_collector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (count >= objspace->profile.size) { | |
objspace->profile.size += 1000; | |
objspace->profile.record = realloc(objspace->profile.record, sizeof(gc_profile_record) * objspace->profile.size); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static VALUE | |
gc_profile_total_time(VALUE self) | |
{ | |
double time = 0; | |
rb_objspace_t *objspace = &rb_objspace; | |
size_t i; | |
if (objspace->profile.run && objspace->profile.count) { | |
for (i = 0; i < objspace->profile.count; i++) { | |
time += objspace->profile.record[i].gc_time; | |
} | |
} | |
return DBL2NUM(time); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(main):001:0> GC::BasicProfiler.enabled? | |
=> false | |
irb(main):002:0> GC::BasicProfiler.enable | |
=> nil | |
irb(main):003:0> GC::BasicProfiler.enabled? | |
=> true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment