benchmark-ips 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.txt +14 -0
- data/lib/benchmark/compare.rb +1 -1
- data/lib/benchmark/ips.rb +9 -3
- data/lib/benchmark/ips/job.rb +6 -5
- data/lib/benchmark/ips/report.rb +5 -5
- data/test/test_benchmark_ips.rb +15 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac378dafa55fa25f223374c352d9fce265a73a1d
|
4
|
+
data.tar.gz: edcbad0a3ed40b69793e18b52b40b4d2d73b72fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 427e884910dc92a0e50ceb825ff36770b70c0dcee9088f56d3e090867986f6c8d12d176c7a671d7b964f15c12c2ae6edd4c87b532c6c68bdd351c0508c03fd90
|
7
|
+
data.tar.gz: 3db5f1f4445eb0b2c4985633a197abf58be95f9a2bb01282bda329c2880916e1c25c5cd0ec94b2a17adbdc667e3e8829dd46fa428ef13dc41cf3327136564d89
|
data/History.txt
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
=== 2.3.0 / 2015-07-20
|
2
|
+
|
3
|
+
* 2 minor features:
|
4
|
+
* Support keyword arguments
|
5
|
+
* Allow any datatype for labels (use #to_s conversion)
|
6
|
+
|
7
|
+
* 1 doc/test changes:
|
8
|
+
* Newer Travis for 1.8.7, ree, and 2.2.2
|
9
|
+
|
10
|
+
* 3 PRs merged:
|
11
|
+
* Merge pull request #41 from kbrock/kwargs-support
|
12
|
+
* Merge pull request #42 from kbrock/newer_travis
|
13
|
+
* Merge pull request #43 from kbrock/non_to_s_labels
|
14
|
+
|
1
15
|
=== 2.2.0 / 2015-05-09
|
2
16
|
|
3
17
|
* 1 minor features:
|
data/lib/benchmark/compare.rb
CHANGED
data/lib/benchmark/ips.rb
CHANGED
@@ -11,17 +11,23 @@ module Benchmark
|
|
11
11
|
module IPS
|
12
12
|
|
13
13
|
# Benchmark-ips Gem version.
|
14
|
-
VERSION = "2.
|
14
|
+
VERSION = "2.3.0"
|
15
15
|
|
16
16
|
# CODENAME of current version.
|
17
|
-
CODENAME = "
|
17
|
+
CODENAME = "Monsoon BBQ"
|
18
18
|
|
19
19
|
# Measure code in block, each code's benchmarked result will display in
|
20
20
|
# iteration per second with standard deviation in given time.
|
21
21
|
# @param time [Integer] Specify how long should benchmark your code in seconds.
|
22
22
|
# @param warmup [Integer] Specify how long should Warmup time run in seconds.
|
23
23
|
# @return [Report]
|
24
|
-
def ips(
|
24
|
+
def ips(*args)
|
25
|
+
if args[0].is_a?(Hash)
|
26
|
+
time, warmup, quiet = args[0].values_at(:time, :warmup, :quiet)
|
27
|
+
else
|
28
|
+
time, warmup, quiet = args
|
29
|
+
end
|
30
|
+
|
25
31
|
suite = nil
|
26
32
|
|
27
33
|
sync, $stdout.sync = $stdout.sync, true
|
data/lib/benchmark/ips/job.rb
CHANGED
@@ -17,7 +17,7 @@ module Benchmark
|
|
17
17
|
# @param action [String, Proc] Code to be benchmarked.
|
18
18
|
# @raise [ArgumentError] Raises when action is not String or not responding to +call+.
|
19
19
|
def initialize(label, action)
|
20
|
-
@label = label
|
20
|
+
@label = label
|
21
21
|
|
22
22
|
if action.kind_of? String
|
23
23
|
compile action
|
@@ -41,7 +41,7 @@ module Benchmark
|
|
41
41
|
end
|
42
42
|
|
43
43
|
# The label of benchmarking action.
|
44
|
-
# @return [
|
44
|
+
# @return [#to_s] Label of action.
|
45
45
|
attr_reader :label
|
46
46
|
|
47
47
|
# The benchmarking action.
|
@@ -52,10 +52,11 @@ module Benchmark
|
|
52
52
|
# Otherwise add a new line and 20 whitespaces.
|
53
53
|
# @return [String] Right justified label.
|
54
54
|
def label_rjust
|
55
|
-
|
56
|
-
|
55
|
+
label = @label.to_s
|
56
|
+
if label.size > 20
|
57
|
+
"#{label}\n#{' ' * 20}"
|
57
58
|
else
|
58
|
-
|
59
|
+
label.rjust(20)
|
59
60
|
end
|
60
61
|
end
|
61
62
|
|
data/lib/benchmark/ips/report.rb
CHANGED
@@ -17,7 +17,7 @@ module Benchmark
|
|
17
17
|
# @param [Float] ips_sd Standard deviation of iterations per second.
|
18
18
|
# @param [Integer] cycles Number of Cycles.
|
19
19
|
def initialize(label, us, iters, ips, ips_sd, cycles)
|
20
|
-
@label = label
|
20
|
+
@label = label
|
21
21
|
@microseconds = us
|
22
22
|
@iterations = iters
|
23
23
|
@ips = ips
|
@@ -100,7 +100,7 @@ module Benchmark
|
|
100
100
|
# Return header with padding if +@label+ is < length of 20.
|
101
101
|
# @return [String] Right justified header (+@label+).
|
102
102
|
def header
|
103
|
-
@label.rjust(20)
|
103
|
+
@label.to_s.rjust(20)
|
104
104
|
end
|
105
105
|
|
106
106
|
# Return string repesentation of Entry object.
|
@@ -149,9 +149,9 @@ module Benchmark
|
|
149
149
|
def data
|
150
150
|
@data ||= @entries.collect do |entry|
|
151
151
|
{
|
152
|
-
name
|
153
|
-
ips
|
154
|
-
stddev
|
152
|
+
:name => entry.label,
|
153
|
+
:ips => entry.ips,
|
154
|
+
:stddev => entry.ips_sd
|
155
155
|
}
|
156
156
|
end
|
157
157
|
end
|
data/test/test_benchmark_ips.rb
CHANGED
@@ -12,6 +12,14 @@ class TestBenchmarkIPS < Minitest::Test
|
|
12
12
|
$stdout = @old_stdout
|
13
13
|
end
|
14
14
|
|
15
|
+
def test_kwargs
|
16
|
+
Benchmark.ips(:time => 1, :warmup => 1, :quiet => false) do |x|
|
17
|
+
x.report("sleep 0.25") { sleep(0.25) }
|
18
|
+
end
|
19
|
+
|
20
|
+
assert $stdout.string.size > 0
|
21
|
+
end
|
22
|
+
|
15
23
|
def test_output
|
16
24
|
Benchmark.ips(1) do |x|
|
17
25
|
x.report("operation") { 100 * 100 }
|
@@ -26,6 +34,12 @@ class TestBenchmarkIPS < Minitest::Test
|
|
26
34
|
end
|
27
35
|
|
28
36
|
assert $stdout.string.size.zero?
|
37
|
+
|
38
|
+
Benchmark.ips(:quiet => true) do |x|
|
39
|
+
x.report("operation") { 100 * 100 }
|
40
|
+
end
|
41
|
+
|
42
|
+
assert $stdout.string.size.zero?
|
29
43
|
end
|
30
44
|
|
31
45
|
def test_ips
|
@@ -108,7 +122,7 @@ class TestBenchmarkIPS < Minitest::Test
|
|
108
122
|
|
109
123
|
rep = report.entries.first
|
110
124
|
|
111
|
-
assert_equal
|
125
|
+
assert_equal :sleep_a_quarter_second, rep.label
|
112
126
|
assert_equal 4*5, rep.iterations
|
113
127
|
assert_in_delta 4.0, rep.ips, 0.2
|
114
128
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: benchmark-ips
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Phoenix
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '5.
|
19
|
+
version: '5.6'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '5.
|
26
|
+
version: '5.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rdoc
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|