summaryrefslogtreecommitdiff
path: root/benchmark/gc/gcbench.rb
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-05 22:13:08 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-05 22:13:08 +0000
commit400a9a7bc285b16a692cdd3d5253de88728990d7 (patch)
tree5b996330061ca7436bd4faff4ea302e34ef96658 /benchmark/gc/gcbench.rb
parent4b7c15faa79aec86979b04b664ead1d3b953a188 (diff)
* benchmark/gc/gcbench.rb: add some options to make quiet.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'benchmark/gc/gcbench.rb')
-rw-r--r--benchmark/gc/gcbench.rb28
1 files changed, 22 insertions, 6 deletions
diff --git a/benchmark/gc/gcbench.rb b/benchmark/gc/gcbench.rb
index a7aef48..16d728a 100644
--- a/benchmark/gc/gcbench.rb
+++ b/benchmark/gc/gcbench.rb
@@ -1,6 +1,14 @@
-
require 'benchmark'
require 'pp'
+require 'optparse'
+
+$list = true
+$gcprof = true
+
+opt = OptionParser.new
+opt.on('-q'){$list = false}
+opt.on('-d'){$gcprof = fales}
+opt.parse!(ARGV)
script = File.join(File.dirname(__FILE__), ARGV.shift)
script += '.rb' unless FileTest.exist?(script)
@@ -8,15 +16,23 @@ raise "#{script} not found" unless FileTest.exist?(script)
puts "Script: #{script}"
-GC::Profiler.enable
+if $gcprof
+ GC::Profiler.enable
+end
+
tms = Benchmark.measure{|x|
load script
}
-gc_time = GC::Profiler.total_time
-GC::Profiler.report if RUBY_VERSION >= '2.0.0' # before 1.9.3, report() may run infinite loop
-GC::Profiler.disable
-pp GC.stat
+gc_time = 0
+
+if $gcprof
+ gc_time = GC::Profiler.total_time
+ GC::Profiler.report if $list and RUBY_VERSION >= '2.0.0' # before 1.9.3, report() may run infinite loop
+ GC::Profiler.disable
+end
+
+pp GC.stat
desc = "#{RUBY_VERSION}#{RUBY_PATCHLEVEL >= 0 ? "p#{RUBY_PATCHLEVEL}" : "dev"}"
name = File.basename(script, '.rb')