On Fri, 2008-07-25 at 23:59 +0900, Narihiro Nakamura wrote:
> Hi.
> 
> make profiler for GC.
> 
> == usage
> GC::Profiler.enable
> 
> :
> :
> :
> # gc is invoked several times
> 
> GC::Profiler.report
> 
> ---------- out -------------
> GC 10 invokes.
> Index	Invoke Time(sec)	Use Size(byte)	Total Size(byte)	Total Object	GC time(ms)
> 1 	0.016 			338420 		360448 			18018 		0.40000000000000007772
> 2 	0.024 			605640 		622592 			31122 		0.00000000000000008843
> 3 	0.040 			1080320 	1097728 		54873 		0.00000000000000022972
> 4 	0.060			1931460 	1949696 		97461 		0.40010000000000034426
> 5 	0.100 			3470040 	3489792 		174447 		0.79999999999999971134
> 6 	0.168 			6236240 	6258688 		312858 		1.20009999999999994458
> 
> 
> 2008303 used objects 52 free objects and 2008355 total objects in Heap.
> Index	Count		%		Kind (class)
> 1 	1500000 	74.68799092 	Child
> 2 	500000 		24.89599697 	Parent
> 3 	5986 		0.29805488 	Object
> 4 	1648 		0.08205721 	String
> 5 	417 		0.02076326 	Class
> 6 	81 		0.00403315 	Encoding
> 8 	48 		0.00239002 	RubyVM::InstructionSequence
> 9 	23 		0.00114522 	Float
> 10 	20 		0.00099584 	Module
> 11 	17 		0.00084646 	Array
> 12 	16 		0.00079667 	Hash
> 13 	10 		0.00049792 	Regexp
> 14 	9 		0.00044813 	Enumerable
> 15 	5 		0.00024896 	Comparable
> 16 	3 		0.00014938 	IO
> 17 	3 		0.00014938 	Precision
> 18 	2 		0.00009958 	Bignum
> 19 	1 		0.00004979 	RubyVM::Env
> 20 	1 		0.00004979 	RubyVM
> 21 	1 		0.00004979 	Complex
> 22 	1 		0.00004979 	NoMemoryError
> 23 	1 		0.00004979 	Binding
> 24 	1 		0.00004979 	SystemStackError
> 25 	1 		0.00004979 	ThreadGroup
> 26 	1 		0.00004979 	Thread
> 27 	1 		0.00004979 	File::Constants
> 28 	1 		0.00004979 	ARGF.class
> 29 	1 		0.00004979 	Mutex
> 30 	1 		0.00004979 	Data
> 31 	1 		0.00004979 	fatal
> 32 	1 		0.00004979 	Kernel
> 33 	1 		0.00004979 	Gem::QuickLoader
> ----------------------------
> 
> == use module and method introduce
> * GC::Profiler
> for Profiler
> 
> * GC::Profiler.enable?
> returns current status of GC profile mode.
> 
> * GC::Profiler.enable
> updates GC profile mode.
> start profiler for GC.
> 
> * GC::Profiler.disable
> stop profiler.
> 
> * GC::Profiler.clear
> clear before profile data.
> 
> * GC::Profiler.report
> Please quote the above-mentioned.
> 
> * GC::Profiler.format
> return string of GC::Profiler.report
> 
> * GC::Profiler.data
> Report profile data to wrap hash.
> It returns a hash as :
> [{:GC_TIME => 0.001, :HEAP_USE_SIZE => 342840,
> :HEAP_TOTAL_SIZE=>360360}, ... ]
> 
> * ObjectSpace.count_classes
> Counts classes for each type.
> It returns a hash as :
> {:TOTAL=>10000, :FREE=>3011, :String=>6, :Array=>404, ...}
> 
> 
> == merit
> 1. find memory leak
> Now, not get detail info in heap.
> ObjectSpace.count_classes, will be help to find memory leak.
> 
> 2. Performance tuning
> This provide simple way to get detail data of gc, and get heap
> size change data by gc.
> This will be help to performance tuning.
> 
> == patch
> patch file append to mail.
> 
> == Please tell me idea for this
> For example, more good method name, want more output data,
> and this propose is bad idea... etc
> 
> thanks.
> 
> nari
> 

Excellent idea!! Now, can all the other implementers build something
like this? ;)
-- 
M. Edward (Ed) Borasky
ruby-perspectives.blogspot.com

"A mathematician is a machine for turning coffee into theorems." --
Alfrd Rnyi via Paul Erds