benchmark-ips 2.9.3 → 2.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +6 -0
- data/lib/benchmark/compare.rb +44 -8
- data/lib/benchmark/ips/job.rb +4 -2
- data/lib/benchmark/ips/report.rb +2 -2
- data/lib/benchmark/ips/stats/bootstrap.rb +4 -0
- data/lib/benchmark/ips/stats/sd.rb +4 -0
- data/lib/benchmark/ips.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0516f3e1e35f43a8fe32a6f32357aa124478ba54228ffe57d928cfc1231851bc
|
4
|
+
data.tar.gz: d62da6a6c1d2696b7667bd125ffe6bb2c33b3d61da5c393e729d7ca8a3d70ee7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b644d293980f1ac9e3158abbe4f2c9d44d23185878edb9cb3861f3ca4f6837d557f89f8eb19bfcc42a45f53f3d112f2fe3ab22fc85a9633ede7e678b5fb90336
|
7
|
+
data.tar.gz: afe9972cdecdb2f42d4946afbac3d02cb3ead3a3d47a804960026ea77487cf885f6ddd7368edb13c522ee11e251599bf953d3d9a8172411c10e7259f7e9352b2
|
data/History.md
CHANGED
data/lib/benchmark/compare.rb
CHANGED
@@ -26,31 +26,67 @@ module Benchmark
|
|
26
26
|
# Reduce using to_proc: 247295.4 i/s - 1.13x slower
|
27
27
|
#
|
28
28
|
# Besides regular Calculating report, this will also indicates which one is slower.
|
29
|
+
#
|
30
|
+
# +x.compare!+ also takes an +order: :baseline+ option.
|
31
|
+
#
|
32
|
+
# Example:
|
33
|
+
# > Benchmark.ips do |x|
|
34
|
+
# x.report('Reduce using block') { [*1..10].reduce { |sum, n| sum + n } }
|
35
|
+
# x.report('Reduce using tag') { [*1..10].reduce(:+) }
|
36
|
+
# x.report('Reduce using to_proc') { [*1..10].reduce(&:+) }
|
37
|
+
# x.compare!(order: :baseline)
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
# Calculating -------------------------------------
|
41
|
+
# Reduce using block 886.202k (± 2.2%) i/s - 4.521M in 5.103774s
|
42
|
+
# Reduce using tag 1.821M (± 1.6%) i/s - 9.111M in 5.004183s
|
43
|
+
# Reduce using to_proc 895.948k (± 1.6%) i/s - 4.528M in 5.055368s
|
44
|
+
#
|
45
|
+
# Comparison:
|
46
|
+
# Reduce using block: 886202.5 i/s
|
47
|
+
# Reduce using tag: 1821055.0 i/s - 2.05x (± 0.00) faster
|
48
|
+
# Reduce using to_proc: 895948.1 i/s - same-ish: difference falls within error
|
49
|
+
#
|
50
|
+
# The first report is considered the baseline against which other reports are compared.
|
29
51
|
module Compare
|
30
52
|
|
31
53
|
# Compare between reports, prints out facts of each report:
|
32
54
|
# runtime, comparative speed difference.
|
33
55
|
# @param entries [Array<Report::Entry>] Reports to compare.
|
34
|
-
def compare(*entries)
|
56
|
+
def compare(*entries, order: :fastest)
|
35
57
|
return if entries.size < 2
|
36
58
|
|
37
|
-
|
38
|
-
|
39
|
-
|
59
|
+
case order
|
60
|
+
when :baseline
|
61
|
+
baseline = entries.shift
|
62
|
+
sorted = entries.sort_by{ |e| e.stats.central_tendency }.reverse
|
63
|
+
when :fastest
|
64
|
+
sorted = entries.sort_by{ |e| e.stats.central_tendency }.reverse
|
65
|
+
baseline = sorted.shift
|
66
|
+
else
|
67
|
+
raise ArgumentError, "Unknwon order: #{order.inspect}"
|
68
|
+
end
|
40
69
|
|
41
70
|
$stdout.puts "\nComparison:"
|
42
71
|
|
43
|
-
$stdout.printf "%20s: %10.1f i/s\n",
|
72
|
+
$stdout.printf "%20s: %10.1f i/s\n", baseline.label.to_s, baseline.stats.central_tendency
|
44
73
|
|
45
74
|
sorted.each do |report|
|
46
75
|
name = report.label.to_s
|
47
76
|
|
48
77
|
$stdout.printf "%20s: %10.1f i/s - ", name, report.stats.central_tendency
|
49
78
|
|
50
|
-
if report.stats.overlaps?(
|
79
|
+
if report.stats.overlaps?(baseline.stats)
|
51
80
|
$stdout.print "same-ish: difference falls within error"
|
81
|
+
elsif report.stats.central_tendency > baseline.stats.central_tendency
|
82
|
+
speedup, error = report.stats.speedup(baseline.stats)
|
83
|
+
$stdout.printf "%.2fx ", speedup
|
84
|
+
if error
|
85
|
+
$stdout.printf " (± %.2f)", error
|
86
|
+
end
|
87
|
+
$stdout.print " faster"
|
52
88
|
else
|
53
|
-
slowdown, error = report.stats.slowdown(
|
89
|
+
slowdown, error = report.stats.slowdown(baseline.stats)
|
54
90
|
$stdout.printf "%.2fx ", slowdown
|
55
91
|
if error
|
56
92
|
$stdout.printf " (± %.2f)", error
|
@@ -61,7 +97,7 @@ module Benchmark
|
|
61
97
|
$stdout.puts
|
62
98
|
end
|
63
99
|
|
64
|
-
footer =
|
100
|
+
footer = baseline.stats.footer
|
65
101
|
$stdout.puts footer.rjust(40) if footer
|
66
102
|
|
67
103
|
$stdout.puts
|
data/lib/benchmark/ips/job.rb
CHANGED
@@ -65,6 +65,7 @@ module Benchmark
|
|
65
65
|
@run_single = false
|
66
66
|
@json_path = false
|
67
67
|
@compare = false
|
68
|
+
@compare_order = :fastest
|
68
69
|
@held_path = nil
|
69
70
|
@held_results = nil
|
70
71
|
|
@@ -117,8 +118,9 @@ module Benchmark
|
|
117
118
|
end
|
118
119
|
|
119
120
|
# Run comparison utility.
|
120
|
-
def compare!
|
121
|
+
def compare!(order: :fastest)
|
121
122
|
@compare = true
|
123
|
+
@compare_order = order
|
122
124
|
end
|
123
125
|
|
124
126
|
# Return true if results are held while multiple Ruby invocations
|
@@ -373,7 +375,7 @@ module Benchmark
|
|
373
375
|
|
374
376
|
# Run comparison of entries in +@full_report+.
|
375
377
|
def run_comparison
|
376
|
-
@full_report.run_comparison if compare?
|
378
|
+
@full_report.run_comparison(@compare_order) if compare?
|
377
379
|
end
|
378
380
|
|
379
381
|
# Generate json from +@full_report+.
|
data/lib/benchmark/ips/report.rb
CHANGED
@@ -176,8 +176,8 @@ module Benchmark
|
|
176
176
|
end
|
177
177
|
|
178
178
|
# Run comparison of entries.
|
179
|
-
def run_comparison
|
180
|
-
Benchmark.compare(*@entries)
|
179
|
+
def run_comparison(order)
|
180
|
+
Benchmark.compare(*@entries, order: order)
|
181
181
|
end
|
182
182
|
|
183
183
|
# Generate json from Report#data to given path.
|
data/lib/benchmark/ips.rb
CHANGED
@@ -18,10 +18,10 @@ module Benchmark
|
|
18
18
|
module IPS
|
19
19
|
|
20
20
|
# Benchmark-ips Gem version.
|
21
|
-
VERSION = "2.
|
21
|
+
VERSION = "2.10.0"
|
22
22
|
|
23
23
|
# CODENAME of current version.
|
24
|
-
CODENAME = "
|
24
|
+
CODENAME = "Watashi Wa Genki"
|
25
25
|
|
26
26
|
# Measure code in block, each code's benchmarked result will display in
|
27
27
|
# iteration per second with standard deviation in given time.
|