Project

General

Profile

Feature #2480 ยป gc_prof_totaltime.patch

wanabe (_ wanabe), 03/03/2010 11:17 PM

View differences:

NEWS (working copy)
* File.realpath
* File.realdirpath
* GC::Profiler
* new methods:
* GC::Profiler.total_time
* IO
* new method:
* IO#fdatasync
gc.c (working copy)
}
/*
* call-seq:
* GC::Profiler.total_time -> float
*
* return total time that GC used. (msec)
*/
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);
}
/*
* The <code>GC</code> module provides an interface to Ruby's mark and
* sweep garbage collection mechanism. Some of the underlying methods
* are also available via the <code>ObjectSpace</code> module.
......
rb_define_singleton_method(rb_mProfiler, "clear", gc_profile_clear, 0);
rb_define_singleton_method(rb_mProfiler, "result", gc_profile_result, 0);
rb_define_singleton_method(rb_mProfiler, "report", gc_profile_report, -1);
rb_define_singleton_method(rb_mProfiler, "total_time", gc_profile_total_time, 0);
rb_mObSpace = rb_define_module("ObjectSpace");
rb_define_module_function(rb_mObSpace, "each_object", os_each_obj, -1);
    (1-1/1)