better-benchmark 0.8.6 → 0.8.7

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTc2OWI4OTQ3ZDg3M2FiNmQ3YTE3NmFmZmRhMmVlMWYyZGYzNWY5Yg==
4
+ Zjk4NGViMGUxNTI0M2JiNTFhOTQ2ODFkZmU2ZjFhNjI2ODI3NjRkMw==
5
5
  data.tar.gz: !binary |-
6
- Y2Y3NzViNzA4MGE2OWVmYzkyMmU0MDdkZGQxOGQzYTBjM2YzZWE0Zg==
7
- !binary "U0hBNTEy":
6
+ NjM3YWU5MTg1MmU4ZGZiNTE3YmE0YjI1MDkzYjljOGQ3MmRkNDRkOA==
7
+ SHA512:
8
8
  metadata.gz: !binary |-
9
- N2RjNzBlNDAyMWRkYjY0NzdhYmJhYTJjMmZiNzE2ZTJhZmE1NTBjNmM2YTRm
10
- MDEzZDY1NDYyMTU2ZDQ0YWIyZDBjNDQ0M2I2NGQ1MDdhNWY3YWU2NjNmNzBm
11
- M2ZhMDJmMmQ5ODE1NzE1ODhjZjg3Y2ZkNDVjNjcwN2Q0MDMyZDc=
9
+ ZGI3ODdiMmVkMTA0YjIwZGIzN2FmMGIzMzhmZWQwYjEwNmRkZmQ4MzFiMmJi
10
+ MGM2YTJlMjU5Mjc5OWMyZmY0NDEzODBjMTcxODU2ZGYwNjk0NjVmY2I5MDcz
11
+ MzY4Yjc3NTU1MWE5OGVlOGEyZGJmOGQ1OGVjZmEzMTg4MzRkZTA=
12
12
  data.tar.gz: !binary |-
13
- NGRkMzIxMDc4ZWJmOWFmNzY4OWJmYjVhNGNkZjU3NjFhZTM4NDJjYjFhOWVh
14
- M2Y5MjEwNWU5OWI0ZWYwYmMxYTMzNTAwNWVhM2IzM2JkNTNmN2Q0M2M1Mjdk
15
- YzI2ZGE4ZjNkMzk1MDFlMzQ0Y2RiZGI1ZTBhNjUyN2VhYzRlODI=
13
+ ZDNkNDBlNDQ2Mzc5OWVmNTVmZTcxZmM2ZTk2Zjc4YjA5MmVjMDQ1YTk5NTI1
14
+ NGM0YzIzZDY1MjcxZDg2YzVkYjhhZDhmNTM4OTFkYWI0NmYzYTY3NGIzZTg1
15
+ ZTc3MjM3NmE3MjdhYTllNGZhYmQwYzkwMDY4OWI1YzNmZWVlODc=
data/README.md CHANGED
@@ -17,6 +17,15 @@ Statistically correct benchmarking for Ruby.
17
17
  Change the argument of `--with-R-dir` to whatever is appropriate for your system
18
18
  if either of the above don't work.
19
19
 
20
+ ### With Bundler
21
+
22
+ Bundler needs to be configured to use the build option:
23
+
24
+ # Linux:
25
+ bundle config build.rsruby --with-R-dir=/usr/lib/R
26
+ # OSX:
27
+ bundle config build.rsruby --with-R-dir=/Library/Frameworks/R.framework/Resources
28
+
20
29
  ## Usage
21
30
 
22
31
  ### Comparing code blocks
@@ -7,7 +7,7 @@ require 'better-benchmark/comparer'
7
7
 
8
8
  module Benchmark
9
9
 
10
- BETTER_BENCHMARK_VERSION = '0.8.6'
10
+ BETTER_BENCHMARK_VERSION = '0.8.7'
11
11
  DEFAULT_REQUIRED_SIGNIFICANCE = 0.01
12
12
 
13
13
  def self.write_realtime( data_dir, &block )
@@ -47,15 +47,18 @@ module Benchmark
47
47
  }
48
48
  end
49
49
 
50
- # Options:
51
- # :iterations
52
- # The number of times to execute the pair of blocks.
53
- # :inner_iterations
54
- # Used to increase the time taken per iteration.
55
- # :required_significance
56
- # Maximum allowed p value in order to declare the results statistically significant.
57
- # :verbose
58
- # Whether to print a dot for each iteration (as a sort of progress meter).
50
+ # @param options [Hash]
51
+ # @option options [Fixnum] :iterations
52
+ # The number of times to execute the pair of blocks.
53
+ # @option options [Fixnum] :inner_iterations
54
+ # Used to increase the time taken per iteration.
55
+ # @option options [Fixnum] :warmup_iterations
56
+ # How many inner iterations to run beforehand, and not measure the time for.
57
+ # This number does not reduce the number of :inner_iterations .
58
+ # @option options [Float] :required_significance
59
+ # Maximum allowed p value in order to declare the results statistically significant.
60
+ # @option options [Boolean] :verbose
61
+ # Whether to print a dot for each iteration (as a sort of progress meter).
59
62
  #
60
63
  # To use better-benchmark properly, it is important to set :iterations and
61
64
  # :inner_iterations properly. There are a few things to bear in mind:
@@ -66,7 +69,7 @@ module Benchmark
66
69
  # small (or else random variance will muddle the results). Aim for at least
67
70
  # 1.0 seconds per iteration.
68
71
  # (3) Minimize the proportion of any warmup time (and cooldown time) of one
69
- # block run.
72
+ # block run (or use :warmup_iterations to eliminate this factor entirely).
70
73
  #
71
74
  # In order to achieve these goals, you will need to tweak :inner_iterations
72
75
  # based on your situation. The exact number you should use will depend on
@@ -74,15 +77,6 @@ module Benchmark
74
77
  # by the blocks. For code blocks that execute extremely rapidly, you may
75
78
  # need hundreds of thousands of :inner_iterations.
76
79
  def self.compare_realtime( options = {}, &block1 )
77
- options[ :iterations ] ||= 20
78
- options[ :inner_iterations ] ||= 1
79
-
80
- if options[ :iterations ] > 30
81
- warn "The number of iterations is set to #{options[ :iterations ]}. " +
82
- "Using too many iterations may make the test results less reliable. " +
83
- "It is recommended to increase the number of :inner_iterations instead."
84
- end
85
-
86
80
  ComparisonPartial.new( block1, options )
87
81
  end
88
82
 
@@ -1,33 +1,51 @@
1
1
  module Benchmark
2
2
  class ComparisonPartial
3
+ # @param options [Hash] @see Benchmark.compare_realtime
3
4
  def initialize( block, options )
4
5
  @block1 = block
5
6
  @options = options
7
+
8
+ @options[:iterations] ||= 20
9
+ @options[:inner_iterations] ||= 1
10
+ @options[:warmup_iterations] ||= 0
11
+
12
+ if @options[:iterations] > 30
13
+ warn "The number of iterations is set to #{@options[:iterations]}. " +
14
+ "Using too many iterations may make the test results less reliable. " +
15
+ "It is recommended to increase the number of :inner_iterations instead."
16
+ end
6
17
  end
7
18
 
8
19
  def with( &block2 )
9
20
  times1 = []
10
21
  times2 = []
11
22
 
12
- (1..@options[ :iterations ]).each do |iteration|
13
- if @options[ :verbose ]
23
+ (1..@options[:iterations]).each do |iteration|
24
+ if @options[:verbose]
14
25
  $stdout.print "."; $stdout.flush
15
26
  end
16
27
 
28
+ @options[:warmup_iterations].times do |i|
29
+ @block1.call( iteration )
30
+ end
17
31
  times1 << Benchmark.realtime do
18
- @options[ :inner_iterations ].times do |i|
32
+ @options[:inner_iterations].times do |i|
19
33
  @block1.call( iteration )
20
34
  end
21
35
  end
36
+
37
+ @options[:warmup_iterations].times do |i|
38
+ block2.call( iteration )
39
+ end
22
40
  times2 << Benchmark.realtime do
23
- @options[ :inner_iterations ].times do |i|
41
+ @options[:inner_iterations].times do |i|
24
42
  block2.call( iteration )
25
43
  end
26
44
  end
27
45
  end
28
46
 
29
- ::Benchmark.compare_times( times1, times2, @options[ :required_significance ] )
47
+ ::Benchmark.compare_times( times1, times2, @options[:required_significance] )
30
48
  end
31
49
  alias to with
32
50
  end
33
- end
51
+ end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: better-benchmark
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.6
4
+ version: 0.8.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pistos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-13 00:00:00.000000000 Z
11
+ date: 2015-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rsruby
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
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
26
  version: '0'
27
27
  description: Statistically correct benchmarking for Ruby.
@@ -45,7 +45,8 @@ files:
45
45
  - bin/bbench
46
46
  - bin/bbench-compare
47
47
  homepage: http://github.com/Pistos/better-benchmark
48
- licenses: []
48
+ licenses:
49
+ - MIT
49
50
  metadata: {}
50
51
  post_install_message:
51
52
  rdoc_options: []
@@ -64,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
65
  requirements:
65
66
  - ! 'The R project: http://www.r-project.org/'
66
67
  rubyforge_project: better-benchmark
67
- rubygems_version: 2.0.3
68
+ rubygems_version: 2.1.11
68
69
  signing_key:
69
70
  specification_version: 4
70
71
  summary: Statistically correct benchmarking for Ruby.