e$B!!$5$5$@$G$9!%e(B
e$B!!:#$^$G2?2se(B GC e$B$r$d$C$?$+D4$Y$k$?$a$Ne(B GC.count
e$B$H$$$&$N$,$"$k$N$G$9$,!$e(B
e$B$3$l$^$G$Ne(B GC e$B$K$+$+$C$?;~4V$rJV$9e(B GC.time
e$B$H$$$&%a%=%C%I$rDI2C$9$k$N$Oe(B
e$B$I$&$G$7$g$&$+!%e(B
e$B!!e(BGC::Profiler
e$B$r;H$($P!$;w$?$h$&$J$3$H$O=PMh$k$h$&$J5$$,$9$k$N$G$9$,!$e(B
e$B$3$NMQES$N$?$a$@$1$K;H$&$N$O$A$g$C$H=E$$$7!$@07A$5$l$?J8;zNs$G$7$+7k2L$,e(B
e$B<h$l$J$$$N$G;H$$$E$i$$$N$Ge(B…e$B!%e(B
Index: gc.c
— gc.c (e$B%j%S%8%g%se(B 23657)
+++ gc.c (e$B:n6H%3%T!<e(B)
@@ -356,6 +356,7 @@
} profile;
struct gc_list *global_list;
unsigned int count;
- double time;
int gc_stress;
} rb_objspace_t;
@@ -2207,6 +2208,8 @@
{
struct gc_list *list;
rb_thread_t *th = GET_THREAD();
-
double invoke_time = getrusage_time();
-
INIT_GC_PROF_PARAMS;
if (GC_NOTIFY) printf(“start garbage_collect()\n”);
@@ -2286,6 +2289,9 @@GC_PROF_TIMER_STOP;
if (GC_NOTIFY) printf(“end garbage_collect()\n”); -
objspace->time += getrusage_time() - invoke_time;
-
return Qtrue;
}
@@ -2950,6 +2956,12 @@
return UINT2NUM((&rb_objspace)->count);
}
+static VALUE
+gc_time(VALUE self)
+{
- return DBL2NUM((&rb_objspace)->time);
+}
#if CALC_EXACT_MALLOC_SIZE
/*
- call-seq:
@@ -3122,6 +3134,7 @@
rb_define_singleton_method(rb_mGC, “stress”, gc_stress_get, 0);
rb_define_singleton_method(rb_mGC, “stress=”, gc_stress_set, 1);
rb_define_singleton_method(rb_mGC, “count”, gc_count, 0);
-
rb_define_singleton_method(rb_mGC, “time”, gc_time, 0);
rb_define_method(rb_mGC, “garbage_collect”, rb_gc_start, 0);rb_mProfiler = rb_define_module_under(rb_mGC, “Profiler”);