Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added benchmark

  • Loading branch information...
commit b982009c298400a1661e1ebaa154d9eaf81cb6d7 1 parent f79d830
Claudio Bustos authored
70 benchmark/benchmark.rb
View
@@ -0,0 +1,70 @@
+# Compares rserve, rinruby and rsruby
+# in retrieval and assign of information
+$:.unshift(File.dirname(__FILE__)+"/../lib")
+
+require 'rubygems'
+require 'rserve'
+require 'rinruby'
+require 'benchmark'
+data_size=10000
+tries=50
+con=Rserve::Connection.new
+data=data_size.times.map {rand()}
+data_integer=data_size.times.map {rand(100)}
+Benchmark.bm(30) do |x|
+ x.report("assign '1' rinruby") {
+ tries.times {
+ R.a=1
+ }
+ }
+ x.report("assign '1' rserve") {
+ con.assign("a", 1)
+ }
+
+ x.report("assign double(#{data_size}) rinruby") {
+ tries.times {
+ R.a=data
+ }
+ }
+ x.report("assign double(#{data_size}) rserve") {
+ con.assign("a", data)
+ }
+
+ x.report("void_eval rinruby") {
+ tries.times {
+ R.eval("1",false)
+ }
+ }
+ x.report("void_eval rserve") {
+ tries.times {
+ con.void_eval("1")
+ }
+ }
+ # Assign data
+ R.a=1
+ con.assign('a',1)
+ x.report("get '1' rinruby") {
+ tries.times {
+ R.pull('a')
+ }
+ }
+ x.report("get '1' rserve") {
+ tries.times {
+ con.eval('a').to_ruby
+ }
+ }
+
+ R.a=data
+ con.assign('a',data)
+
+ x.report("get double(#{data_size}) rinruby") {
+ tries.times {
+ R.pull('a')
+ }
+ }
+ x.report("get double(#{data_size}) rserve") {
+ tries.times {
+ con.eval('a').to_ruby
+ }
+ }
+end
BIN  benchmark/comparison_2010_06_07.xls
View
Binary file not shown
45 benchmark/plot.rb
View
@@ -0,0 +1,45 @@
+# Creates a graph with multiple size assignment and retrieval
+
+require 'rubygems'
+require 'rserve'
+require 'rinruby'
+require 'benchmark'
+require 'statsample'
+
+max=40
+
+con=Rserve::Connection.new
+rserve_assign = []
+rserve_retrieve = []
+rinruby_assign = []
+rinruby_retrieve = []
+max.times.map {|x|
+ puts "Rserve #{x}"
+ start=Time.new.to_f
+ con.assign('a',(x*100+1).times.map {rand})
+ a=Time.new.to_f-start
+
+ start=Time.new.to_f
+
+ con.eval('a').to_f
+
+ b=Time.new.to_f-start
+
+ rserve_assign.push(a)
+ rserve_retrieve.push(b)
+}
+rinruby=max.times.map {|x|
+
+ puts "Rinruby #{x}"
+ start=Time.new.to_f
+ R.assign("a", (x*100+1).times.map {rand})
+ a=Time.new.to_f-start
+ start=Time.new.to_f
+ R.pull('a')
+ b=Time.new.to_f-start
+ rinruby_assign.push(a)
+ rinruby_retrieve.push(b)
+}
+
+ds_assign={'times'=>(1..max).map {|v| v*100+1}.to_scale,'rserve assign'=> rserve_assign.to_scale, 'rserve retrieve'=>rserve_retrieve.to_scale, 'rinruby assign'=>rinruby_assign.to_scale, 'rinruby retrieve'=>rinruby_retrieve.to_scale}.to_dataset
+Statsample::CSV.write(ds_assign,'comparison.csv')
Please sign in to comment.
Something went wrong with that request. Please try again.