rspec-benchmark 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module Benchmark
5
- VERSION = "0.5.1"
5
+ VERSION = "0.6.0"
6
6
  end # Benchmark
7
7
  end # RSpec
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-benchmark
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Murach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-11 00:00:00.000000000 Z
11
+ date: 2020-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-malloc
@@ -16,76 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.0
19
+ version: '0.2'
20
20
  type: :runtime
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: 0.1.0
26
+ version: '0.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: benchmark-perf
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.5.0
33
+ version: '0.6'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.5.0
40
+ version: '0.6'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: benchmark-trend
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.3.0
47
+ version: '0.4'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.3.0
54
+ version: '0.4'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 3.0.0
62
- - - "<"
63
- - !ruby/object:Gem::Version
64
- version: 4.0.0
61
+ version: '3.0'
65
62
  type: :runtime
66
63
  prerelease: false
67
64
  version_requirements: !ruby/object:Gem::Requirement
68
65
  requirements:
69
66
  - - ">="
70
67
  - !ruby/object:Gem::Version
71
- version: 3.0.0
72
- - - "<"
73
- - !ruby/object:Gem::Version
74
- version: 4.0.0
75
- - !ruby/object:Gem::Dependency
76
- name: bundler
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: '1.5'
82
- type: :development
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: '1.5'
68
+ version: '3.0'
89
69
  - !ruby/object:Gem::Dependency
90
70
  name: rake
91
71
  requirement: !ruby/object:Gem::Requirement
@@ -103,49 +83,37 @@ dependencies:
103
83
  description: Performance testing matchers for RSpec to set expectations on speed,
104
84
  resources usage and scalibility.
105
85
  email:
106
- - me@piotrmurach.com
86
+ - piotr@piotrmurach.com
107
87
  executables: []
108
88
  extensions: []
109
- extra_rdoc_files: []
89
+ extra_rdoc_files:
90
+ - README.md
91
+ - CHANGELOG.md
92
+ - LICENSE.txt
110
93
  files:
111
94
  - CHANGELOG.md
112
95
  - LICENSE.txt
113
96
  - README.md
114
- - Rakefile
115
97
  - lib/rspec-benchmark.rb
116
98
  - lib/rspec/benchmark.rb
117
99
  - lib/rspec/benchmark/allocation_matcher.rb
118
100
  - lib/rspec/benchmark/comparison_matcher.rb
119
101
  - lib/rspec/benchmark/complexity_matcher.rb
120
102
  - lib/rspec/benchmark/configuration.rb
121
- - lib/rspec/benchmark/format_time.rb
103
+ - lib/rspec/benchmark/formatter.rb
122
104
  - lib/rspec/benchmark/iteration_matcher.rb
123
105
  - lib/rspec/benchmark/matchers.rb
124
106
  - lib/rspec/benchmark/timing_matcher.rb
125
107
  - lib/rspec/benchmark/version.rb
126
- - rspec-benchmark.gemspec
127
- - spec/spec_helper.rb
128
- - spec/unit/comparison_matcher_spec.rb
129
- - spec/unit/composable_spec.rb
130
- - spec/unit/configuration_spec.rb
131
- - spec/unit/format_time_spec.rb
132
- - spec/unit/perform_allocation_spec.rb
133
- - spec/unit/perform_at_least_spec.rb
134
- - spec/unit/perform_constant_spec.rb
135
- - spec/unit/perform_exponential_spec.rb
136
- - spec/unit/perform_linear_spec.rb
137
- - spec/unit/perform_logarithmic_spec.rb
138
- - spec/unit/perform_power_spec.rb
139
- - spec/unit/perform_under_spec.rb
140
- - tasks/coverage.rake
141
- - tasks/spec.rake
142
108
  homepage: https://github.com/piotrmurach/rspec-benchmark
143
109
  licenses:
144
110
  - MIT
145
111
  metadata:
112
+ bug_tracker_uri: https://github.com/piotrmurach/rspec-benchmark/issues
113
+ changelog_uri: https://github.com/piotrmurach/rspec-benchmark/blob/master/CHANGELOG.md
114
+ documentation_uri: https://www.rubydoc.info/gems/rspec-benchmark
146
115
  homepage_uri: https://github.com/piotrmurach/rspec-benchmark
147
116
  source_code_uri: https://github.com/piotrmurach/rspec-benchmark
148
- changelog_uri: https://github.com/piotrmurach/rspec-benchmark/blob/master/CHANGELOG.md
149
117
  post_install_message:
150
118
  rdoc_options: []
151
119
  require_paths:
@@ -161,21 +129,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
129
  - !ruby/object:Gem::Version
162
130
  version: '0'
163
131
  requirements: []
164
- rubygems_version: 3.0.3
132
+ rubygems_version: 3.1.2
165
133
  signing_key:
166
134
  specification_version: 4
167
135
  summary: Performance testing matchers for RSpec
168
- test_files:
169
- - spec/spec_helper.rb
170
- - spec/unit/comparison_matcher_spec.rb
171
- - spec/unit/composable_spec.rb
172
- - spec/unit/configuration_spec.rb
173
- - spec/unit/format_time_spec.rb
174
- - spec/unit/perform_allocation_spec.rb
175
- - spec/unit/perform_at_least_spec.rb
176
- - spec/unit/perform_constant_spec.rb
177
- - spec/unit/perform_exponential_spec.rb
178
- - spec/unit/perform_linear_spec.rb
179
- - spec/unit/perform_logarithmic_spec.rb
180
- - spec/unit/perform_power_spec.rb
181
- - spec/unit/perform_under_spec.rb
136
+ test_files: []
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require "bundler/gem_tasks"
4
-
5
- FileList['tasks/**/*.rake'].each(&method(:import))
6
-
7
- desc 'Run all specs'
8
- task ci: %w[ coverage ]
9
-
10
- task default: :spec
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RSpec
4
- module Benchmark
5
- # Format time for easy matcher reporting
6
- #
7
- # @param [Float] time
8
- # the time to format
9
- #
10
- # @return [String]
11
- # the human readable time value
12
- #
13
- # @api public
14
- def format_time(time)
15
- if time >= 100.0
16
- "%.0f sec" % [time]
17
- elsif time >= 1.0
18
- "%.3g sec" % [time]
19
- elsif time >= 1e-3
20
- "%.3g ms" % [time * 1e3]
21
- elsif time >= 1e-6
22
- "%.3g μs" % [time * 1e6]
23
- else
24
- "%.0f ns" % [time * 1e9]
25
- end
26
- end
27
- module_function :format_time
28
- end # Benchmark
29
- end # RSpec
@@ -1,37 +0,0 @@
1
- lib = File.expand_path('../lib', __FILE__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'rspec/benchmark/version'
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "rspec-benchmark"
7
- spec.version = RSpec::Benchmark::VERSION
8
- spec.authors = ["Piotr Murach"]
9
- spec.email = ["me@piotrmurach.com"]
10
- spec.summary = %q{Performance testing matchers for RSpec}
11
- spec.description = %q{Performance testing matchers for RSpec to set expectations on speed, resources usage and scalibility.}
12
- spec.homepage = "https://github.com/piotrmurach/rspec-benchmark"
13
- spec.license = "MIT"
14
-
15
- if spec.respond_to?(:metadata)
16
- spec.metadata["homepage_uri"] = spec.homepage
17
- spec.metadata["source_code_uri"] = "https://github.com/piotrmurach/rspec-benchmark"
18
- spec.metadata["changelog_uri"] = "https://github.com/piotrmurach/rspec-benchmark/blob/master/CHANGELOG.md"
19
- end
20
-
21
- spec.files = Dir['{lib,spec}/**/*.rb']
22
- spec.files += Dir['tasks/*', 'rspec-benchmark.gemspec']
23
- spec.files += Dir['README.md', 'CHANGELOG.md', 'LICENSE.txt', 'Rakefile']
24
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
25
- spec.test_files = spec.files.grep(%r{^spec/})
26
- spec.require_paths = ["lib"]
27
-
28
- spec.required_ruby_version = '>= 2.1.0'
29
-
30
- spec.add_dependency 'benchmark-malloc', '~> 0.1.0'
31
- spec.add_dependency 'benchmark-perf', '~> 0.5.0'
32
- spec.add_dependency 'benchmark-trend', '~> 0.3.0'
33
- spec.add_dependency 'rspec', '>= 3.0.0', '< 4.0.0'
34
-
35
- spec.add_development_dependency 'bundler', '>= 1.5'
36
- spec.add_development_dependency 'rake'
37
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- if ENV['COVERAGE'] || ENV['TRAVIS']
4
- require 'simplecov'
5
- require 'coveralls'
6
-
7
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
8
- SimpleCov::Formatter::HTMLFormatter,
9
- Coveralls::SimpleCov::Formatter
10
- ]
11
-
12
- SimpleCov.start do
13
- command_name 'spec'
14
- add_filter 'spec'
15
- end
16
- end
17
-
18
- require 'bundler/setup'
19
- require 'rspec/benchmark'
20
-
21
- RSpec.configure do |config|
22
- config.include(RSpec::Benchmark::Matchers)
23
-
24
- config.expect_with :rspec do |c|
25
- c.syntax = :expect
26
- end
27
-
28
- config.disable_monkey_patching!
29
-
30
- config.warnings = true
31
-
32
- if config.files_to_run.one?
33
- config.default_formatter = 'doc'
34
- end
35
-
36
- config.profile_examples = 2
37
- end
@@ -1,212 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RSpec::Benchmark::ComparisonMatcher::Matcher do
4
-
5
- it "validates comparison type" do
6
- expect {
7
- described_class.new(-> { 1 + 2 }, :unknown)
8
- }.to raise_error(ArgumentError, /comparison_type must be :faster or :slower, not `:unknown`/)
9
- end
10
-
11
- it "raises expectation error when not given a block" do
12
- expect {
13
- expect(1 + 1).to perform_faster_than { 'x' * 10 * 1024 }
14
- }.to raise_error(RSpec::Expectations::ExpectationNotMetError,
15
- "expected given block to perform faster than comparison block, but was not a block")
16
- end
17
-
18
- it "allows to configure matcher timings" do
19
- allow(::Benchmark::Perf::Iteration).to receive(:run).and_return(100)
20
-
21
- expect {
22
- 1 << 1
23
- }.to perform_faster_than.within(0.3).warmup(0.2) {
24
- 'x' * 10 * 1024
25
- }.once
26
-
27
- expect(::Benchmark::Perf::Iteration).to have_received(:run).with(time: 0.3, warmup: 0.2).twice
28
- end
29
-
30
- context 'algorithms comparison' do
31
- def clamp(num, min, max)
32
- [num, min, max].sort[1]
33
- end
34
-
35
- def clamp_fast(num, min, max)
36
- num > max ? max : (num < min ? min : num)
37
- end
38
-
39
- it "infers one implementation faster than another" do
40
- num = rand(1_000)
41
- expect {
42
- clamp_fast(num, num / 2, num * 2)
43
- }.to perform_faster_than {
44
- clamp(num, num / 2, num * 2)
45
- }.at_least(1.5).times
46
- end
47
- end
48
-
49
- describe "expect { ... }.to perform_faster_than(...)" do
50
- it "passes if the block performs faster than sample" do
51
- expect { 1 << 1 }.to perform_faster_than { 'x' * 10 * 1024 }
52
- end
53
-
54
- it "fails if the block performs slower than sample" do
55
- expect {
56
- expect { 'x' * 10 * 1024 }.to perform_faster_than { 1 << 1 }
57
- }.to raise_error(/expected given block to perform faster than comparison block, but performed slower by \d+.\d+ times/)
58
- end
59
-
60
- context 'with exact count' do
61
- it "passes if the block performs faster than sample" do
62
- expect { 1 << 1 }.to perform_faster_than { 1 << 1 }.exactly(1).times
63
- end
64
-
65
- it "passes if the block performs specified number of times" do
66
- expect { 1 << 1 }.to perform_faster_than { 1 << 1 }.once
67
- end
68
- end
69
-
70
- context "with at_least count" do
71
- it "passes if the block performs faster by count times" do
72
- expect { 1 << 1 }.to perform_faster_than { 'x' * 10 * 1024 }.at_least(2)
73
- end
74
-
75
- it "fails if the block doesn't perform faster by count times" do
76
- expect {
77
- expect {
78
- 'x' * 10 * 1024
79
- }.to perform_faster_than { 1 << 1 }.at_least(2).times
80
- }.to raise_error(/expected given block to perform faster than comparison block by at_least \d+ times, but performed slower by \d+.\d+ times/)
81
- end
82
- end
83
-
84
- context "with at_most count" do
85
- it "passes if the block performs faster than sample" do
86
- expect { 1 << 1 }.to perform_faster_than { 'x' * 10 * 1024 }.at_most(125)
87
- end
88
-
89
- it "fails if the block performs faster than sample more than in 20 times" do
90
- expect {
91
- expect {
92
- 1 << 1
93
- }.to perform_faster_than { 'x' * 10 * 1024 }.at_most(2).times
94
- }.to raise_error(/expected given block to perform faster than comparison block by at_most \d+ times, but performed faster by \d+.\d+ times/)
95
- end
96
- end
97
- end
98
-
99
- context "expect { ... }.not_to perform_faster_than(...)" do
100
- it "passes if the block performs slower than sample" do
101
- expect { 'x' * 10 * 1024 }.not_to perform_faster_than { 1 << 1 }
102
- end
103
-
104
- it "fails if the block performs faster than sample" do
105
- expect {
106
- expect { 1 << 1 }.not_to perform_faster_than { 'x' * 10 * 1024 }
107
- }.to raise_error(/expected given block not to perform faster than comparison block, but performed faster by \d+.\d+ times/)
108
- end
109
-
110
- context 'with at_least count' do
111
- it "passes if the block performs slower than sample" do
112
- expect {
113
- 'x' * 10 * 1024
114
- }.not_to perform_faster_than { 1 << 1 }.at_least(20).times
115
- end
116
-
117
- it "fails if the block performs faster than sample" do
118
- expect {
119
- expect {
120
- 1 << 1
121
- }.not_to perform_faster_than { 'x' * 10 * 1024 }.at_least(2).times
122
- }.to raise_error(/expected given block not to perform faster than comparison block by at_least \d+ times, but performed faster by \d+.\d+ times/)
123
- end
124
- end
125
- end
126
-
127
- describe "expect { ... }.not_to perform_slower_than(...)" do
128
- it "passes if the block performs faster than sample" do
129
- expect { 1 << 1 }.not_to perform_slower_than { 'x' * 10 * 1024 }
130
- end
131
-
132
- it "fails if the block performs slower than sample" do
133
- expect {
134
- expect { 'x' * 10 * 1024 }.not_to perform_slower_than { 1 << 1 }
135
- }.to raise_error(/expected given block not to perform slower than comparison block, but performed slower by \d+.\d+ times/)
136
- end
137
-
138
- context "with at_least count" do
139
- it "passes if the block performs faster than sample" do
140
- expect {
141
- 1 << 1
142
- }.not_to perform_slower_than { 'x' * 10 * 1024 }.at_least(2).times
143
- end
144
-
145
- it "fails if the block performs slower than sample" do
146
- expect {
147
- expect {
148
- 'x' * 10 * 1024
149
- }.not_to perform_slower_than { 1 << 1 }.at_least(5).times
150
- }.to raise_error(/expected given block not to perform slower than comparison block by at_least \d+ times, but performed slower by \d+.\d+ times/)
151
- end
152
- end
153
- end
154
-
155
- describe "expect { ... }.to perform_slower_than(...)" do
156
- it "passes if the block performs slower than sample" do
157
- expect { 'x' * 10 * 1024 }.to perform_slower_than { 1 << 1 }
158
- end
159
-
160
- it "fails if the block performs faster than sample" do
161
- expect {
162
- expect { 1 << 1 }.to perform_slower_than { 'x' * 10 * 1024 }
163
- }.to raise_error(/expected given block to perform slower than comparison block, but performed faster by \d+.\d+ times/)
164
- end
165
-
166
- context "with at_least count" do
167
- it "passes if the block does performs slower than sample" do
168
- expect {
169
- 'x' * 10 * 1024
170
- }.to perform_slower_than { 1 << 1 }.at_least(15).times
171
- end
172
-
173
- it "fails if the block count compared with sample is too high" do
174
- expect {
175
- expect {
176
- 'x' * 10 * 1024
177
- }.to perform_slower_than { 1 << 1 }.at_least(200).times
178
- }.to raise_error(/expected given block to perform slower than comparison block by at_least 200 times, but performed slower by \d+.\d+ time/)
179
- end
180
-
181
- it "fails if the block does perform faster than sample" do
182
- expect {
183
- expect {
184
- 1 << 1
185
- }.to perform_slower_than { 'x' * 10 * 1024 }.at_least(2).times
186
- }.to raise_error(/expected given block to perform slower than comparison block by at_least \d+ times, but performed faster by \d+.\d+ times/)
187
- end
188
- end
189
-
190
- context "with exact count" do
191
- it "passes if the block performs slower than sample" do
192
- expect { 1 << 1 }.to perform_slower_than { 1 << 1 }.exactly(1).times
193
- end
194
- end
195
-
196
- context "with at_most count" do
197
- it "passes if the block performs faster than sample" do
198
- expect {
199
- 'x' * 10 * 1024
200
- }.to perform_slower_than { 1 << 1 }.at_most(125).times
201
- end
202
-
203
- it "fails if the block performs slower than sample more than in 20 times" do
204
- expect {
205
- expect {
206
- 'x' * 10 * 1024
207
- }.to perform_slower_than { 1 << 1 }.at_most(2).times
208
- }.to raise_error(/expected given block to perform slower than comparison block by at_most \d+ times, but performed slower by \d+.\d+ times/)
209
- end
210
- end
211
- end
212
- end