зеркало из https://github.com/github/ruby.git
* 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
This commit is contained in:
Родитель
787cdae5df
Коммит
c322f10ad9
|
@ -1,3 +1,7 @@
|
||||||
|
Tue Apr 30 23:18:00 2013 Zachary Scott <zachary@zacharyscott.net>
|
||||||
|
|
||||||
|
* lib/benchmark.rb: Update Benchmark results on newer CPU
|
||||||
|
|
||||||
Tue Apr 30 12:31:40 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Tue Apr 30 12:31:40 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* proc.c (mproc, mlambda): use frozen core methods instead of plain
|
* proc.c (mproc, mlambda): use frozen core methods instead of plain
|
||||||
|
|
|
@ -19,15 +19,15 @@
|
||||||
# used to execute Ruby code.
|
# used to execute Ruby code.
|
||||||
#
|
#
|
||||||
# * Measure the time to construct the string given by the expression
|
# * Measure the time to construct the string given by the expression
|
||||||
# <code>"a"*1_000_000</code>:
|
# <code>"a"*1_000_000_000</code>:
|
||||||
#
|
#
|
||||||
# require 'benchmark'
|
# 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
|
# 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
|
# the user and system CPU times, and the elapsed real time. The unit
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
#
|
#
|
||||||
# require 'benchmark'
|
# require 'benchmark'
|
||||||
#
|
#
|
||||||
# n = 50000
|
# n = 5000000
|
||||||
# Benchmark.bm do |x|
|
# Benchmark.bm do |x|
|
||||||
# x.report { for i in 1..n; a = "1"; end }
|
# x.report { for i in 1..n; a = "1"; end }
|
||||||
# x.report { n.times do ; a = "1"; end }
|
# x.report { n.times do ; a = "1"; end }
|
||||||
|
@ -47,15 +47,15 @@
|
||||||
# The result:
|
# The result:
|
||||||
#
|
#
|
||||||
# user system total real
|
# user system total real
|
||||||
# 1.033333 0.016667 1.016667 ( 0.492106)
|
# 1.010000 0.000000 1.010000 ( 1.014479)
|
||||||
# 1.483333 0.000000 1.483333 ( 0.694605)
|
# 1.000000 0.000000 1.000000 ( 0.998261)
|
||||||
# 1.516667 0.000000 1.516667 ( 0.711077)
|
# 0.980000 0.000000 0.980000 ( 0.981335)
|
||||||
#
|
#
|
||||||
# * Continuing the previous example, put a label in each report:
|
# * Continuing the previous example, put a label in each report:
|
||||||
#
|
#
|
||||||
# require 'benchmark'
|
# require 'benchmark'
|
||||||
#
|
#
|
||||||
# n = 50000
|
# n = 5000000
|
||||||
# Benchmark.bm(7) do |x|
|
# Benchmark.bm(7) do |x|
|
||||||
# x.report("for:") { for i in 1..n; a = "1"; end }
|
# x.report("for:") { for i in 1..n; a = "1"; end }
|
||||||
# x.report("times:") { n.times do ; a = "1"; end }
|
# x.report("times:") { n.times do ; a = "1"; end }
|
||||||
|
@ -65,10 +65,9 @@
|
||||||
# The result:
|
# The result:
|
||||||
#
|
#
|
||||||
# user system total real
|
# user system total real
|
||||||
# for: 1.050000 0.000000 1.050000 ( 0.503462)
|
# for: 1.010000 0.000000 1.010000 ( 1.015688)
|
||||||
# times: 1.533333 0.016667 1.550000 ( 0.735473)
|
# times: 1.000000 0.000000 1.000000 ( 1.003611)
|
||||||
# upto: 1.500000 0.016667 1.516667 ( 0.711239)
|
# upto: 1.030000 0.000000 1.030000 ( 1.028098)
|
||||||
#
|
|
||||||
#
|
#
|
||||||
# * The times for some benchmarks depend on the order in which items
|
# * The times for some benchmarks depend on the order in which items
|
||||||
# are run. These differences are due to the cost of memory
|
# are run. These differences are due to the cost of memory
|
||||||
|
@ -88,14 +87,13 @@
|
||||||
# The result:
|
# The result:
|
||||||
#
|
#
|
||||||
# Rehearsal -----------------------------------------
|
# Rehearsal -----------------------------------------
|
||||||
# sort! 11.928000 0.010000 11.938000 ( 12.756000)
|
# sort! 1.490000 0.010000 1.500000 ( 1.490520)
|
||||||
# sort 13.048000 0.020000 13.068000 ( 13.857000)
|
# sort 1.460000 0.000000 1.460000 ( 1.463025)
|
||||||
# ------------------------------- total: 25.006000sec
|
# -------------------------------- total: 2.960000sec
|
||||||
#
|
#
|
||||||
# user system total real
|
# user system total real
|
||||||
# sort! 12.959000 0.010000 12.969000 ( 13.793000)
|
# sort! 1.460000 0.000000 1.460000 ( 1.460465)
|
||||||
# sort 12.007000 0.000000 12.007000 ( 12.791000)
|
# sort 1.450000 0.010000 1.460000 ( 1.448327)
|
||||||
#
|
|
||||||
#
|
#
|
||||||
# * Report statistics of sequential experiments with unique labels,
|
# * Report statistics of sequential experiments with unique labels,
|
||||||
# using the #benchmark method:
|
# using the #benchmark method:
|
||||||
|
@ -103,7 +101,7 @@
|
||||||
# require 'benchmark'
|
# require 'benchmark'
|
||||||
# include Benchmark # we need the CAPTION and FORMAT constants
|
# include Benchmark # we need the CAPTION and FORMAT constants
|
||||||
#
|
#
|
||||||
# n = 50000
|
# n = 5000000
|
||||||
# Benchmark.benchmark(CAPTION, 7, FORMAT, ">total:", ">avg:") do |x|
|
# Benchmark.benchmark(CAPTION, 7, FORMAT, ">total:", ">avg:") do |x|
|
||||||
# tf = x.report("for:") { for i in 1..n; a = "1"; end }
|
# tf = x.report("for:") { for i in 1..n; a = "1"; end }
|
||||||
# tt = x.report("times:") { n.times do ; a = "1"; end }
|
# tt = x.report("times:") { n.times do ; a = "1"; end }
|
||||||
|
@ -114,11 +112,11 @@
|
||||||
# The result:
|
# The result:
|
||||||
#
|
#
|
||||||
# user system total real
|
# user system total real
|
||||||
# for: 1.016667 0.016667 1.033333 ( 0.485749)
|
# for: 0.950000 0.000000 0.950000 ( 0.952039)
|
||||||
# times: 1.450000 0.016667 1.466667 ( 0.681367)
|
# times: 0.980000 0.000000 0.980000 ( 0.984938)
|
||||||
# upto: 1.533333 0.000000 1.533333 ( 0.722166)
|
# upto: 0.950000 0.000000 0.950000 ( 0.946787)
|
||||||
# >total: 4.000000 0.033333 4.033333 ( 1.889282)
|
# >total: 2.880000 0.000000 2.880000 ( 2.883764)
|
||||||
# >avg: 1.333333 0.011111 1.344444 ( 0.629761)
|
# >avg: 0.960000 0.000000 0.960000 ( 0.961255)
|
||||||
|
|
||||||
module Benchmark
|
module Benchmark
|
||||||
|
|
||||||
|
@ -145,7 +143,7 @@ module Benchmark
|
||||||
# require 'benchmark'
|
# require 'benchmark'
|
||||||
# include Benchmark # we need the CAPTION and FORMAT constants
|
# include Benchmark # we need the CAPTION and FORMAT constants
|
||||||
#
|
#
|
||||||
# n = 50000
|
# n = 5000000
|
||||||
# Benchmark.benchmark(CAPTION, 7, FORMAT, ">total:", ">avg:") do |x|
|
# Benchmark.benchmark(CAPTION, 7, FORMAT, ">total:", ">avg:") do |x|
|
||||||
# tf = x.report("for:") { for i in 1..n; a = "1"; end }
|
# tf = x.report("for:") { for i in 1..n; a = "1"; end }
|
||||||
# tt = x.report("times:") { n.times do ; a = "1"; end }
|
# tt = x.report("times:") { n.times do ; a = "1"; end }
|
||||||
|
@ -156,11 +154,11 @@ module Benchmark
|
||||||
# Generates:
|
# Generates:
|
||||||
#
|
#
|
||||||
# user system total real
|
# user system total real
|
||||||
# for: 1.016667 0.016667 1.033333 ( 0.485749)
|
# for: 0.970000 0.000000 0.970000 ( 0.970493)
|
||||||
# times: 1.450000 0.016667 1.466667 ( 0.681367)
|
# times: 0.990000 0.000000 0.990000 ( 0.989542)
|
||||||
# upto: 1.533333 0.000000 1.533333 ( 0.722166)
|
# upto: 0.970000 0.000000 0.970000 ( 0.972854)
|
||||||
# >total: 4.000000 0.033333 4.033333 ( 1.889282)
|
# >total: 2.930000 0.000000 2.930000 ( 2.932889)
|
||||||
# >avg: 1.333333 0.011111 1.344444 ( 0.629761)
|
# >avg: 0.976667 0.000000 0.976667 ( 0.977630)
|
||||||
#
|
#
|
||||||
|
|
||||||
def benchmark(caption = "", label_width = nil, format = nil, *labels) # :yield: report
|
def benchmark(caption = "", label_width = nil, format = nil, *labels) # :yield: report
|
||||||
|
@ -187,7 +185,7 @@ module Benchmark
|
||||||
#
|
#
|
||||||
# require 'benchmark'
|
# require 'benchmark'
|
||||||
#
|
#
|
||||||
# n = 50000
|
# n = 5000000
|
||||||
# Benchmark.bm(7) do |x|
|
# Benchmark.bm(7) do |x|
|
||||||
# x.report("for:") { for i in 1..n; a = "1"; end }
|
# x.report("for:") { for i in 1..n; a = "1"; end }
|
||||||
# x.report("times:") { n.times do ; a = "1"; end }
|
# x.report("times:") { n.times do ; a = "1"; end }
|
||||||
|
@ -197,9 +195,9 @@ module Benchmark
|
||||||
# Generates:
|
# Generates:
|
||||||
#
|
#
|
||||||
# user system total real
|
# user system total real
|
||||||
# for: 1.050000 0.000000 1.050000 ( 0.503462)
|
# for: 0.960000 0.000000 0.960000 ( 0.957966)
|
||||||
# times: 1.533333 0.016667 1.550000 ( 0.735473)
|
# times: 0.960000 0.000000 0.960000 ( 0.960423)
|
||||||
# upto: 1.500000 0.016667 1.516667 ( 0.711239)
|
# upto: 0.950000 0.000000 0.950000 ( 0.954864)
|
||||||
#
|
#
|
||||||
|
|
||||||
def bm(label_width = 0, *labels, &blk) # :yield: report
|
def bm(label_width = 0, *labels, &blk) # :yield: report
|
||||||
|
@ -233,13 +231,13 @@ module Benchmark
|
||||||
# Generates:
|
# Generates:
|
||||||
#
|
#
|
||||||
# Rehearsal -----------------------------------------
|
# Rehearsal -----------------------------------------
|
||||||
# sort! 11.928000 0.010000 11.938000 ( 12.756000)
|
# sort! 1.440000 0.010000 1.450000 ( 1.446833)
|
||||||
# sort 13.048000 0.020000 13.068000 ( 13.857000)
|
# sort 1.440000 0.000000 1.440000 ( 1.448257)
|
||||||
# ------------------------------- total: 25.006000sec
|
# -------------------------------- total: 2.890000sec
|
||||||
#
|
#
|
||||||
# user system total real
|
# user system total real
|
||||||
# sort! 12.959000 0.010000 12.969000 ( 13.793000)
|
# sort! 1.460000 0.000000 1.460000 ( 1.458065)
|
||||||
# sort 12.007000 0.000000 12.007000 ( 12.791000)
|
# sort 1.450000 0.000000 1.450000 ( 1.455963)
|
||||||
#
|
#
|
||||||
# #bmbm yields a Benchmark::Job object and returns an array of
|
# #bmbm yields a Benchmark::Job object and returns an array of
|
||||||
# Benchmark::Tms objects.
|
# Benchmark::Tms objects.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче