demo/benchmark.rb in statsample-0.3.1 vs demo/benchmark.rb in statsample-0.3.2

- old
+ new

@@ -8,10 +8,20 @@ nil end }.to_vector v.missing_values=[5,10,20] v.type=:scale +a=[] +b=[] +c=[] +(0..1000).each{|i| + a.push(rand()) + b.push(rand()) + c.push(rand()) +} +ds=Statsample::Dataset.new({'a'=>a.to_vector(:scale),'b'=>b.to_vector(:scale), 'c'=>c.to_vector(:scale)}) + n = 300 if (false) Benchmark.bm(7) do |bench| bench.report("missing or") { for i in 1..n; v.each {|x| !(x.nil? or v.missing_values.include? x) }; end } @@ -23,11 +33,23 @@ bench.report("true") { Statsample::OPTIMIZED=true; for i in 1..n; v.set_valid_data ; end } bench.report("false") { Statsample::OPTIMIZED=false; for i in 1..n; v.set_valid_data ; end } end end - if (true) + Benchmark.bm(7) do |x| + x.report("Alglib coeffs") { for i in 1..n; lr=Statsample::Regression::Multiple::AlglibEngine.new(ds,"c"); lr.coeffs; end } + x.report("GslEngine coeffs") { for i in 1..n; lr=Statsample::Regression::Multiple::GslEngine.new(ds,"c"); lr.coeffs; end } + end + end + if(true) + Benchmark.bm(7) do |x| + x.report("Alglib process") { for i in 1..n; lr=Statsample::Regression::Multiple::AlglibEngine.new(ds,"c"); lr.process([1,2]); end } + x.report("GslEngine process") { for i in 1..n; lr=Statsample::Regression::Multiple::GslEngine.new(ds,"c"); lr.process([1,2]); end } + + end + end + if (false) Benchmark.bm(7) do |x| x.report("mean") { for i in 1..n; v.mean; end } x.report("slow_mean") { for i in 1..n; v.mean_slow; end } end