ruby-changes:14943
From: wanabe <ko1@a...>
Date: Thu, 4 Mar 2010 13:52:03 +0900 (JST)
Subject: [ruby-changes:14943] Ruby:r26814 (trunk): * gc.c (gc_profile_total_time): add GC::Profiler.total_time.
wanabe 2010-03-04 13:51:43 +0900 (Thu, 04 Mar 2010) New Revision: 26814 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26814 Log: * gc.c (gc_profile_total_time): add GC::Profiler.total_time. * NEWS: ditto. Modified files: trunk/ChangeLog trunk/NEWS trunk/gc.c Index: ChangeLog =================================================================== --- ChangeLog (revision 26813) +++ ChangeLog (revision 26814) @@ -1,3 +1,9 @@ +Mon Mar 4 13:14:34 2010 wanabe <s.wanabe@g...> + + * gc.c (gc_profile_total_time): add GC::Profiler.total_time. + + * NEWS: ditto. + Thu Mar 4 10:15:10 2010 NARUSE, Yui <naruse@r...> * complex.c (m_log, m_exp): remove unused functions. Index: gc.c =================================================================== --- gc.c (revision 26813) +++ gc.c (revision 26814) @@ -3129,6 +3129,28 @@ } /* + * 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. @@ -3156,6 +3178,7 @@ 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); Index: NEWS =================================================================== --- NEWS (revision 26813) +++ NEWS (revision 26814) @@ -69,6 +69,10 @@ * File.realpath * File.realdirpath + * GC::Profiler + * new method: + * GC::Profiler.total_time + * IO * new method: * IO#fdatasync -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/