summaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-20 06:18:09 (GMT)
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-20 06:18:09 (GMT)
commit99b10ff471c50358ed0f6864f4cf87857c51a91d (patch)
treee8c951ec1afa18da031e3b140db30823163a61cb /benchmark
parentab7e4592106e0796d5b243c0d0c8629a47351e05 (diff)
* benchmark/gc: create a directory to store GC related benchmark.
* benchmark/gc/gcbench.rb: moved from tool/gcbench.rb. * benchmark/gc/hash(1|2).rb: ditto. * benchmark/gc/rdoc.rb: ditto. * benchmark/gc/null.rb: added. * common.mk: fix rule. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/gc/gcbench.rb27
-rw-r--r--benchmark/gc/hash1.rb11
-rw-r--r--benchmark/gc/hash2.rb7
-rw-r--r--benchmark/gc/null.rb1
-rw-r--r--benchmark/gc/rdoc.rb13
5 files changed, 59 insertions, 0 deletions
diff --git a/benchmark/gc/gcbench.rb b/benchmark/gc/gcbench.rb
new file mode 100644
index 0000000..5fee2a2
--- /dev/null
+++ b/benchmark/gc/gcbench.rb
@@ -0,0 +1,27 @@
+
+require 'benchmark'
+require 'pp'
+
+script = File.join(__dir__, ARGV.shift)
+script += '.rb' unless FileTest.exist?(script)
+raise "#{script} not found" unless FileTest.exist?(script)
+
+puts "Script: #{script}"
+
+GC::Profiler.enable
+tms = Benchmark.measure{|x|
+ load script
+}
+GC::Profiler.report
+pp GC.stat
+
+gc_time = GC::Profiler.total_time
+
+puts
+puts script
+puts Benchmark::CAPTION
+puts tms
+puts "GC total time (sec): #{gc_time}"
+puts
+puts "Summary #{RUBY_DESCRIPTION}\t#{tms.real}\t#{gc_time}\t#{GC.count}"
+puts " (real time in sec, GC time in sec, GC count)"
diff --git a/benchmark/gc/hash1.rb b/benchmark/gc/hash1.rb
new file mode 100644
index 0000000..cb030d4
--- /dev/null
+++ b/benchmark/gc/hash1.rb
@@ -0,0 +1,11 @@
+value = 0.01
+h = {}
+n = 50_000
+
+1.upto(n){|i|
+ h["%020d" % i] = "v-#{i}"
+}
+
+(n * 1_000).times{
+ ''
+}
diff --git a/benchmark/gc/hash2.rb b/benchmark/gc/hash2.rb
new file mode 100644
index 0000000..e8c943f
--- /dev/null
+++ b/benchmark/gc/hash2.rb
@@ -0,0 +1,7 @@
+value = 0.01
+h = {}
+n = 4*(10**6)
+
+1.upto(n){|i|
+ h["%020d" % i] = value * i
+}
diff --git a/benchmark/gc/null.rb b/benchmark/gc/null.rb
new file mode 100644
index 0000000..31c1887
--- /dev/null
+++ b/benchmark/gc/null.rb
@@ -0,0 +1 @@
+# null
diff --git a/benchmark/gc/rdoc.rb b/benchmark/gc/rdoc.rb
new file mode 100644
index 0000000..14c89f5
--- /dev/null
+++ b/benchmark/gc/rdoc.rb
@@ -0,0 +1,13 @@
+require 'rdoc/rdoc'
+require 'tmpdir'
+
+srcdir = File.expand_path('../..', __dir__)
+
+Dir.mktmpdir('rdocbench-'){|d|
+ dir = File.join(d, 'rdocbench')
+ args = %W(--root #{srcdir} --page-dir #{srcdir}/doc --encoding=UTF-8 --no-force-update --all --ri --debug --quiet #{srcdir})
+ args << '--op' << dir
+
+ r = RDoc::RDoc.new
+ r.document args
+}