implement method invocation rb benchmark development
authorMarcel Hlopko <marcel.hlopko@fit.cvut.cz>
Sun, 19 May 2013 15:24:38 +0200
branchdevelopment
changeset 2599 388b25528e07
parent 2598 94ae3f5f4df1
child 2619 bb850b4cdf4e
child 2630 d2cc54aad7c6
implement method invocation rb benchmark
benchmarks/methodinvocation.rb
--- a/benchmarks/methodinvocation.rb	Sat May 18 22:29:48 2013 +0200
+++ b/benchmarks/methodinvocation.rb	Sun May 19 15:24:38 2013 +0200
@@ -1,3 +1,20 @@
 #!/usr/bin/env ruby
-puts "EXECUTION TIME: N/A"
+require 'benchmark'
+
+class MethodInvocation
+  def do_smth
+    self
+  end
+end
 
+results = Benchmark.bmbm do |bm|
+  raise "Expecting one arg - num of invocations" if ARGV.size == 0
+  n = ARGV[0].to_i
+  inst = MethodInvocation.new
+
+  bm.report do 
+    n.times { inst.do_smth }
+  end
+end
+puts "EXECUTION TIME: #{results[0].real * 1000.0}"
+