benchmark-trend 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/README.md +10 -10
- data/benchmark-trend.gemspec +5 -5
- data/lib/benchmark/trend/version.rb +1 -1
- metadata +13 -20
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/examples/fib_constant.rb +0 -16
- data/examples/fib_linear.rb +0 -17
- data/exe/bench-trend +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3e27367eb5b2bd4fdb6f42ae8d142eafb36d20b79391ba1cc316f5e3d816f37
|
4
|
+
data.tar.gz: 5e894156903f8b74f3ce543d1ee01c44567fb1f681b926b8ccfcdc28929773c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb7f6c061e9fafd944f1ec0abc7112ad551a4065875d8496c3d9463552435263ca443c12be24eb457f7be0340dd0d4d16cd67f42be6dc030b2276b52e2890f85
|
7
|
+
data.tar.gz: 3f077ee1c12866e94f3e8b75cb678830386ead23aa6002db3033701862b9da123841855f29dedbe16c918fb7efcd01f9872551996b8b5b07c2f7a40af69e579f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
## [v0.3.0] - 2019-04-21
|
4
|
+
|
5
|
+
### Changed
|
6
|
+
* Change to require Ruby >= 2.0.0
|
7
|
+
* Change to relax development dependencies
|
8
|
+
|
3
9
|
## [v0.2.0] - 2018-09-30
|
4
10
|
|
5
11
|
### Added
|
@@ -17,7 +23,8 @@
|
|
17
23
|
|
18
24
|
## [v0.1.0] - 2018-09-08
|
19
25
|
|
20
|
-
*
|
26
|
+
* Initial implementation and release
|
21
27
|
|
28
|
+
[v0.3.0]: https://github.com/piotrmurach/benchmark-trend/compare/v0.2.0...v0.3.0
|
22
29
|
[v0.2.0]: https://github.com/piotrmurach/benchmark-trend/compare/v0.1.0...v0.2.0
|
23
30
|
[v0.1.0]: https://github.com/piotrmurach/benchmark-trend/compare/v0.1.0
|
data/README.md
CHANGED
@@ -20,7 +20,7 @@
|
|
20
20
|
|
21
21
|
## Why?
|
22
22
|
|
23
|
-
Tests provide safety net that ensures your code works correctly. What you don't know is how fast your code is! How does it scale with different input sizes? Your code may have computational complexity that
|
23
|
+
Tests provide safety net that ensures your code works correctly. What you don't know is how fast your code is! How does it scale with different input sizes? Your code may have computational complexity that doesn't scale with large workloads. It would be good to know before your application goes into production, wouldn't it?
|
24
24
|
|
25
25
|
**Benchmark::Trend** will allow you to uncover performance bugs or confirm that a Ruby code performance scales as expected.
|
26
26
|
|
@@ -54,11 +54,11 @@ Or install it yourself as:
|
|
54
54
|
|
55
55
|
## 1. Usage
|
56
56
|
|
57
|
-
Let's assume we would like to find out behaviour of a
|
57
|
+
Let's assume we would like to find out behaviour of a Fibonacci algorithm:
|
58
58
|
|
59
59
|
```ruby
|
60
60
|
def fibonacci(n)
|
61
|
-
n
|
61
|
+
n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2)
|
62
62
|
end
|
63
63
|
```
|
64
64
|
|
@@ -143,7 +143,7 @@ For example, let's assume you would like to find out asymptotic behaviour of a F
|
|
143
143
|
|
144
144
|
```ruby
|
145
145
|
def fibonacci(n)
|
146
|
-
n
|
146
|
+
n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2)
|
147
147
|
end
|
148
148
|
```
|
149
149
|
|
@@ -254,16 +254,16 @@ print error
|
|
254
254
|
|
255
255
|
### 2.4 fit_at
|
256
256
|
|
257
|
-
If you are
|
257
|
+
If you are interested how a model scales for a given input use `fit_at`. This method expects that there is a fit model generated using [infer_trend](#22-infer_trend).
|
258
258
|
|
259
259
|
For example, measuring Fibonacci recursive algorithm we have the following results:
|
260
260
|
|
261
261
|
```ruby
|
262
262
|
# =>
|
263
|
-
{:trend=>"1.38 * 0.00^x",
|
264
|
-
|
265
|
-
|
266
|
-
|
263
|
+
# {:trend=>"1.38 * 0.00^x",
|
264
|
+
# :slope=>1.382889711685203,
|
265
|
+
# :intercept=>3.822775903539121e-06,
|
266
|
+
# :residual=>0.9052392775178072}
|
267
267
|
```
|
268
268
|
|
269
269
|
And checking model at input of `50`:
|
@@ -311,7 +311,7 @@ trend, trends = Benchmark::Trend.infer_trend(array_sizes) do |n, i|
|
|
311
311
|
end
|
312
312
|
```
|
313
313
|
|
314
|
-
|
314
|
+
Unsurprisingly, we discover that Ruby's `max` call scales linearily with the input size:
|
315
315
|
|
316
316
|
```ruby
|
317
317
|
print trend
|
data/benchmark-trend.gemspec
CHANGED
@@ -6,15 +6,15 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.name = "benchmark-trend"
|
7
7
|
spec.version = Benchmark::Trend::VERSION
|
8
8
|
spec.authors = ["Piotr Murach"]
|
9
|
-
spec.email = [""]
|
9
|
+
spec.email = ["me@piotrmurach.com"]
|
10
10
|
|
11
11
|
spec.summary = %q{Measure pefromance trends of Ruby code based on the input size distribution.}
|
12
12
|
spec.description = %q{Benchmark::Trend will help you estimate the computational complexity of Ruby code by running it on inputs increasing in size, measuring their execution times, and then fitting these observations into a model that best predicts how a given Ruby code will scale as a function of growing workload.}
|
13
13
|
spec.homepage = "https://github.com/piotrmurach/benchmark-trend"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
|
-
spec.files = Dir['{lib,spec
|
17
|
-
spec.files += Dir['
|
16
|
+
spec.files = Dir['{lib,spec}/**/*.rb']
|
17
|
+
spec.files += Dir['tasks/*', 'benchmark-trend.gemspec']
|
18
18
|
spec.files += Dir['README.md', 'CHANGELOG.md', 'LICENSE.txt', 'Rakefile']
|
19
19
|
spec.bindir = "exe"
|
20
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.required_ruby_version = '>= 2.0.0'
|
24
24
|
|
25
|
-
spec.add_development_dependency "bundler", "
|
26
|
-
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "bundler", ">= 1.5.0"
|
26
|
+
spec.add_development_dependency "rake"
|
27
27
|
spec.add_development_dependency "rspec", "~> 3.0"
|
28
28
|
end
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: benchmark-trend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Murach
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.5.0
|
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:
|
26
|
+
version: 1.5.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
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: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -57,9 +57,8 @@ description: Benchmark::Trend will help you estimate the computational complexit
|
|
57
57
|
times, and then fitting these observations into a model that best predicts how a
|
58
58
|
given Ruby code will scale as a function of growing workload.
|
59
59
|
email:
|
60
|
-
-
|
61
|
-
executables:
|
62
|
-
- bench-trend
|
60
|
+
- me@piotrmurach.com
|
61
|
+
executables: []
|
63
62
|
extensions: []
|
64
63
|
extra_rdoc_files: []
|
65
64
|
files:
|
@@ -68,11 +67,6 @@ files:
|
|
68
67
|
- README.md
|
69
68
|
- Rakefile
|
70
69
|
- benchmark-trend.gemspec
|
71
|
-
- bin/console
|
72
|
-
- bin/setup
|
73
|
-
- examples/fib_constant.rb
|
74
|
-
- examples/fib_linear.rb
|
75
|
-
- exe/bench-trend
|
76
70
|
- lib/benchmark-trend.rb
|
77
71
|
- lib/benchmark/trend.rb
|
78
72
|
- lib/benchmark/trend/version.rb
|
@@ -108,8 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
102
|
- !ruby/object:Gem::Version
|
109
103
|
version: '0'
|
110
104
|
requirements: []
|
111
|
-
|
112
|
-
rubygems_version: 2.7.3
|
105
|
+
rubygems_version: 3.0.3
|
113
106
|
signing_key:
|
114
107
|
specification_version: 4
|
115
108
|
summary: Measure pefromance trends of Ruby code based on the input size distribution.
|
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "benchmark/trend"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|
data/bin/setup
DELETED
data/examples/fib_constant.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require_relative '../lib/benchmark-trend'
|
2
|
-
|
3
|
-
# constant
|
4
|
-
def fib_const(n)
|
5
|
-
phi = (1 + Math.sqrt(5))/2
|
6
|
-
(phi ** n / Math.sqrt(5)).round
|
7
|
-
end
|
8
|
-
|
9
|
-
numbers = Benchmark::Trend.range(1, 1400, ratio: 2)
|
10
|
-
trend, trends = Benchmark::Trend.infer_trend(numbers, repeat: 100) do |n|
|
11
|
-
fib_const(n)
|
12
|
-
end
|
13
|
-
|
14
|
-
puts "Trend: #{trend}"
|
15
|
-
puts "Trend data:"
|
16
|
-
pp trends
|
data/examples/fib_linear.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require_relative '../lib/benchmark-trend'
|
2
|
-
|
3
|
-
# linear
|
4
|
-
def fib_iter(n)
|
5
|
-
a, b = 0, 1
|
6
|
-
n.times { a, b = b, a + b}
|
7
|
-
a
|
8
|
-
end
|
9
|
-
|
10
|
-
numbers = Benchmark::Trend.range(1, 20_000)
|
11
|
-
trend, trends = Benchmark::Trend.infer_trend(numbers) do |n|
|
12
|
-
fib_iter(n)
|
13
|
-
end
|
14
|
-
|
15
|
-
puts "Trend: #{trend}"
|
16
|
-
puts "Trend data:"
|
17
|
-
pp trends
|
data/exe/bench-trend
DELETED