mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* gc.c (gc_profile_clear): realloc profile records if its size is
higher than the threshold, GC_PROFILE_RECORD_DEFAULT_SIZE * 2. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4d03af3d9c
commit
fe9fc6df01
3 changed files with 31 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Wed Nov 21 22:08:48 2012 Narihiro Nakamura <authornari@gmail.com>
|
||||||
|
|
||||||
|
* gc.c (gc_profile_clear): realloc profile records if its size is
|
||||||
|
higher than the threshold, GC_PROFILE_RECORD_DEFAULT_SIZE * 2.
|
||||||
|
|
||||||
Wed Nov 21 21:53:29 2012 Tadayoshi Funaba <tadf@dotrb.org>
|
Wed Nov 21 21:53:29 2012 Tadayoshi Funaba <tadf@dotrb.org>
|
||||||
|
|
||||||
* complex.c (nucomp_to_c): added.
|
* complex.c (nucomp_to_c): added.
|
||||||
|
|
11
gc.c
11
gc.c
|
@ -3822,6 +3822,7 @@ wmap_aref(VALUE self, VALUE wmap)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static inline void gc_prof_set_heap_info(rb_objspace_t *, gc_profile_record *);
|
static inline void gc_prof_set_heap_info(rb_objspace_t *, gc_profile_record *);
|
||||||
|
#define GC_PROFILE_RECORD_DEFAULT_SIZE 100
|
||||||
|
|
||||||
static double
|
static double
|
||||||
getrusage_time(void)
|
getrusage_time(void)
|
||||||
|
@ -3866,7 +3867,7 @@ gc_prof_timer_start(rb_objspace_t *objspace)
|
||||||
size_t count = objspace->profile.count;
|
size_t count = objspace->profile.count;
|
||||||
|
|
||||||
if (!objspace->profile.record) {
|
if (!objspace->profile.record) {
|
||||||
objspace->profile.size = 1000;
|
objspace->profile.size = GC_PROFILE_RECORD_DEFAULT_SIZE;
|
||||||
objspace->profile.record = malloc(sizeof(gc_profile_record) * objspace->profile.size);
|
objspace->profile.record = malloc(sizeof(gc_profile_record) * objspace->profile.size);
|
||||||
}
|
}
|
||||||
if (count >= objspace->profile.size) {
|
if (count >= objspace->profile.size) {
|
||||||
|
@ -4076,6 +4077,14 @@ static VALUE
|
||||||
gc_profile_clear(void)
|
gc_profile_clear(void)
|
||||||
{
|
{
|
||||||
rb_objspace_t *objspace = &rb_objspace;
|
rb_objspace_t *objspace = &rb_objspace;
|
||||||
|
|
||||||
|
if (GC_PROFILE_RECORD_DEFAULT_SIZE * 2 < objspace->profile.size) {
|
||||||
|
objspace->profile.size = GC_PROFILE_RECORD_DEFAULT_SIZE * 2;
|
||||||
|
objspace->profile.record = realloc(objspace->profile.record, sizeof(gc_profile_record) * objspace->profile.size);
|
||||||
|
if (!objspace->profile.record) {
|
||||||
|
rb_memerror();
|
||||||
|
}
|
||||||
|
}
|
||||||
MEMZERO(objspace->profile.record, gc_profile_record, objspace->profile.size);
|
MEMZERO(objspace->profile.record, gc_profile_record, objspace->profile.size);
|
||||||
objspace->profile.count = 0;
|
objspace->profile.count = 0;
|
||||||
return Qnil;
|
return Qnil;
|
||||||
|
|
|
@ -118,4 +118,20 @@ class TestGc < Test::Unit::TestCase
|
||||||
ensure
|
ensure
|
||||||
GC::Profiler.disable
|
GC::Profiler.disable
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_profiler_clear
|
||||||
|
GC::Profiler.enable
|
||||||
|
|
||||||
|
GC.start
|
||||||
|
assert_equal(1, GC::Profiler.raw_data.size)
|
||||||
|
GC.clear
|
||||||
|
assert_equal(0, GC::Profiler.raw_data.size)
|
||||||
|
|
||||||
|
200.times{ GC.start }
|
||||||
|
assert_equal(200, GC::Profiler.raw_data.size)
|
||||||
|
GC.clear
|
||||||
|
assert_equal(0, GC::Profiler.raw_data.size)
|
||||||
|
ensure
|
||||||
|
GC::Profiler.disable
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue