From c322f10ad99f9cc964dca4e42179f52450516b74 Mon Sep 17 00:00:00 2001 From: zzak Date: Tue, 30 Apr 2013 14:19:20 +0000 Subject: * lib/benchmark.rb: Update Benchmark results on newer CPU git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40529 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/benchmark.rb | 78 +++++++++++++++++++++++++++----------------------------- 1 file changed, 38 insertions(+), 40 deletions(-) (limited to 'lib') diff --git a/lib/benchmark.rb b/lib/benchmark.rb index f52ba7df34..93b841c451 100644 --- a/lib/benchmark.rb +++ b/lib/benchmark.rb @@ -19,15 +19,15 @@ # used to execute Ruby code. # # * Measure the time to construct the string given by the expression -# "a"*1_000_000: +# "a"*1_000_000_000: # # require 'benchmark' # -# puts Benchmark.measure { "a"*1_000_000 } +# puts Benchmark.measure { "a"*1_000_000_000 } # -# On my machine (FreeBSD 3.2 on P5, 100MHz) this generates: +# On my machine (OSX 10.8.3 on i5 1.7 Ghz) this generates: # -# 1.166667 0.050000 1.216667 ( 0.571355) +# 0.350000 0.400000 0.750000 ( 0.835234) # # This report shows the user CPU time, system CPU time, the sum of # the user and system CPU times, and the elapsed real time. The unit @@ -37,7 +37,7 @@ # # require 'benchmark' # -# n = 50000 +# n = 5000000 # Benchmark.bm do |x| # x.report { for i in 1..n; a = "1"; end } # x.report { n.times do ; a = "1"; end } @@ -47,15 +47,15 @@ # The result: # # user system total real -# 1.033333 0.016667 1.016667 ( 0.492106) -# 1.483333 0.000000 1.483333 ( 0.694605) -# 1.516667 0.000000 1.516667 ( 0.711077) +# 1.010000 0.000000 1.010000 ( 1.014479) +# 1.000000 0.000000 1.000000 ( 0.998261) +# 0.980000 0.000000 0.980000 ( 0.981335) # # * Continuing the previous example, put a label in each report: # # require 'benchmark' # -# n = 50000 +# n = 5000000 # Benchmark.bm(7) do |x| # x.report("for:") { for i in 1..n; a = "1"; end } # x.report("times:") { n.times do ; a = "1"; end } @@ -65,10 +65,9 @@ # The result: # # user system total real -# for: 1.050000 0.000000 1.050000 ( 0.503462) -# times: 1.533333 0.016667 1.550000 ( 0.735473) -# upto: 1.500000 0.016667 1.516667 ( 0.711239) -# +# for: 1.010000 0.000000 1.010000 ( 1.015688) +# times: 1.000000 0.000000 1.000000 ( 1.003611) +# upto: 1.030000 0.000000 1.030000 ( 1.028098) # # * The times for some benchmarks depend on the order in which items # are run. These differences are due to the cost of memory @@ -88,14 +87,13 @@ # The result: # # Rehearsal ----------------------------------------- -# sort! 11.928000 0.010000 11.938000 ( 12.756000) -# sort 13.048000 0.020000 13.068000 ( 13.857000) -# ------------------------------- total: 25.006000sec +# sort! 1.490000 0.010000 1.500000 ( 1.490520) +# sort 1.460000 0.000000 1.460000 ( 1.463025) +# -------------------------------- total: 2.960000sec # # user system total real -# sort! 12.959000 0.010000 12.969000 ( 13.793000) -# sort 12.007000 0.000000 12.007000 ( 12.791000) -# +# sort! 1.460000 0.000000 1.460000 ( 1.460465) +# sort 1.450000 0.010000 1.460000 ( 1.448327) # # * Report statistics of sequential experiments with unique labels, # using the #benchmark method: @@ -103,7 +101,7 @@ # require 'benchmark' # include Benchmark # we need the CAPTION and FORMAT constants # -# n = 50000 +# n = 5000000 # Benchmark.benchmark(CAPTION, 7, FORMAT, ">total:", ">avg:") do |x| # tf = x.report("for:") { for i in 1..n; a = "1"; end } # tt = x.report("times:") { n.times do ; a = "1"; end } @@ -114,11 +112,11 @@ # The result: # # user system total real -# for: 1.016667 0.016667 1.033333 ( 0.485749) -# times: 1.450000 0.016667 1.466667 ( 0.681367) -# upto: 1.533333 0.000000 1.533333 ( 0.722166) -# >total: 4.000000 0.033333 4.033333 ( 1.889282) -# >avg: 1.333333 0.011111 1.344444 ( 0.629761) +# for: 0.950000 0.000000 0.950000 ( 0.952039) +# times: 0.980000 0.000000 0.980000 ( 0.984938) +# upto: 0.950000 0.000000 0.950000 ( 0.946787) +# >total: 2.880000 0.000000 2.880000 ( 2.883764) +# >avg: 0.960000 0.000000 0.960000 ( 0.961255) module Benchmark @@ -145,7 +143,7 @@ module Benchmark # require 'benchmark' # include Benchmark # we need the CAPTION and FORMAT constants # - # n = 50000 + # n = 5000000 # Benchmark.benchmark(CAPTION, 7, FORMAT, ">total:", ">avg:") do |x| # tf = x.report("for:") { for i in 1..n; a = "1"; end } # tt = x.report("times:") { n.times do ; a = "1"; end } @@ -156,11 +154,11 @@ module Benchmark # Generates: # # user system total real - # for: 1.016667 0.016667 1.033333 ( 0.485749) - # times: 1.450000 0.016667 1.466667 ( 0.681367) - # upto: 1.533333 0.000000 1.533333 ( 0.722166) - # >total: 4.000000 0.033333 4.033333 ( 1.889282) - # >avg: 1.333333 0.011111 1.344444 ( 0.629761) + # for: 0.970000 0.000000 0.970000 ( 0.970493) + # times: 0.990000 0.000000 0.990000 ( 0.989542) + # upto: 0.970000 0.000000 0.970000 ( 0.972854) + # >total: 2.930000 0.000000 2.930000 ( 2.932889) + # >avg: 0.976667 0.000000 0.976667 ( 0.977630) # def benchmark(caption = "", label_width = nil, format = nil, *labels) # :yield: report @@ -187,7 +185,7 @@ module Benchmark # # require 'benchmark' # - # n = 50000 + # n = 5000000 # Benchmark.bm(7) do |x| # x.report("for:") { for i in 1..n; a = "1"; end } # x.report("times:") { n.times do ; a = "1"; end } @@ -197,9 +195,9 @@ module Benchmark # Generates: # # user system total real - # for: 1.050000 0.000000 1.050000 ( 0.503462) - # times: 1.533333 0.016667 1.550000 ( 0.735473) - # upto: 1.500000 0.016667 1.516667 ( 0.711239) + # for: 0.960000 0.000000 0.960000 ( 0.957966) + # times: 0.960000 0.000000 0.960000 ( 0.960423) + # upto: 0.950000 0.000000 0.950000 ( 0.954864) # def bm(label_width = 0, *labels, &blk) # :yield: report @@ -233,13 +231,13 @@ module Benchmark # Generates: # # Rehearsal ----------------------------------------- - # sort! 11.928000 0.010000 11.938000 ( 12.756000) - # sort 13.048000 0.020000 13.068000 ( 13.857000) - # ------------------------------- total: 25.006000sec + # sort! 1.440000 0.010000 1.450000 ( 1.446833) + # sort 1.440000 0.000000 1.440000 ( 1.448257) + # -------------------------------- total: 2.890000sec # # user system total real - # sort! 12.959000 0.010000 12.969000 ( 13.793000) - # sort 12.007000 0.000000 12.007000 ( 12.791000) + # sort! 1.460000 0.000000 1.460000 ( 1.458065) + # sort 1.450000 0.000000 1.450000 ( 1.455963) # # #bmbm yields a Benchmark::Job object and returns an array of # Benchmark::Tms objects. -- cgit v1.2.3