summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
Diffstat (limited to 'tool')
-rw-r--r--tool/gcbench.rb24
-rw-r--r--tool/hashbench1.rb11
-rw-r--r--tool/hashbench2.rb7
-rw-r--r--tool/rdocbench.rb21
4 files changed, 44 insertions, 19 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}"
diff --git a/tool/hashbench1.rb b/tool/hashbench1.rb
new file mode 100644
index 0000000000..3e8b0dd95e
--- /dev/null
+++ b/tool/hashbench1.rb
@@ -0,0 +1,11 @@
+value = 0.01
+h = {}
+n = 100_000
+
+1.upto(n){|i|
+ h["%020d" % i] = value * i
+}
+
+(n * 500).times{
+ ''
+}
diff --git a/tool/hashbench2.rb b/tool/hashbench2.rb
new file mode 100644
index 0000000000..e8c943fb21
--- /dev/null
+++ b/tool/hashbench2.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/tool/rdocbench.rb b/tool/rdocbench.rb
index f325f6a187..a248b9a9b7 100644
--- a/tool/rdocbench.rb
+++ b/tool/rdocbench.rb
@@ -1,28 +1,11 @@
-
require 'rdoc/rdoc'
require 'tmpdir'
-require 'benchmark'
-require 'pp'
Dir.mktmpdir('rdocbench-'){|d|
dir = File.join(d, 'rdocbench')
args = ARGV.dup
args << '--op' << dir
- GC::Profiler.enable
- tms = Benchmark.measure{|x|
- r = RDoc::RDoc.new
- r.document args
- }
- GC::Profiler.report
- pp GC.stat
- puts
- puts Benchmark::CAPTION
- puts tms
- puts "GC total time (sec): #{GC::Profiler.total_time}"
- puts
- puts "Summary (ruby): #{RUBY_DESCRIPTION})"
- puts "Summary (real): #{tms.real} sec"
- puts "Summary (gctm): #{GC::Profiler.total_time} sec"
- puts "Summary (gc#) : #{GC.count}"
+ r = RDoc::RDoc.new
+ r.document args
}