summaryrefslogtreecommitdiff
path: root/tool/gcbench.rb
diff options
context:
space:
mode:
Diffstat (limited to 'tool/gcbench.rb')
-rw-r--r--tool/gcbench.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/tool/gcbench.rb b/tool/gcbench.rb
new file mode 100644
index 0000000000..e16cb9ddce
--- /dev/null
+++ b/tool/gcbench.rb
@@ -0,0 +1,24 @@
+
+require 'benchmark'
+require 'pp'
+
+script = ARGV.shift || raise
+
+GC::Profiler.enable
+tms = Benchmark.measure{|x|
+ load script
+}
+GC::Profiler.report
+pp GC.stat
+
+gc_time = GC::Profiler.total_time
+
+puts
+puts Benchmark::CAPTION
+puts tms
+puts "GC total time (sec): #{gc_time}"
+puts
+puts "Summary (ruby): #{RUBY_DESCRIPTION} (#{script})"
+puts "Summary (real): #{tms.real} sec"
+puts "Summary (gctm): #{gc_time} sec"
+puts "Summary (gc#) : #{GC.count}"