benchmark-ips 2.4.0 → 2.4.1

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ae132eff282ec75647b3d3d1301cf42372dcdaf
4
- data.tar.gz: cc8d76ab64858a0682f7fb767fa8e958973cdb3d
3
+ metadata.gz: 9b51b0526730c2f62df99ab99a7b9ee4455bd551
4
+ data.tar.gz: e831277bf0718b4451f172a5f379d9cefc6c7efe
5
5
  SHA512:
6
- metadata.gz: 8a79e55f2f50dfda13b04fd852bfa122a41918e2e74a105cf42dc01f7d65042a089c392f5fe6964c7784e57c7d7ef73fa6fb43546ec5e7f881e9b945a9c9cf26
7
- data.tar.gz: 31bcb112be6fa82299708cc4dfccbe9ac421774ff7ff53da85d6bac1d61cacdc9ef28ec24e07efd96ffb59fbff0e3aee0eb8f180ce4aa90468e223e87de7537e
6
+ metadata.gz: 911bcd01427c54ac09b86ba506fe5c59b79eb0f8bff27ac58b79bfdd084de80aa91d0cec6fda0df9c591d55185ed4c922006039d6b74f597fcfb99045ce80a59
7
+ data.tar.gz: 7453a913d40e0c6751dbc5e69bdfa2cb749c387568ebaebaed9b401bf65c1adc8aa4aa56a7c9ba31f60e0e1ff27cc9473b3c961f6cc2e9538ad5be64e209b583
@@ -1,3 +1,8 @@
1
+ === 2.4.1 / 2016-02-12
2
+
3
+ * 1 bug fix:
4
+ * Add missing files to gem
5
+
1
6
  === 2.4.0 / 2016-02-12
2
7
 
3
8
  * 1 minor features
@@ -5,7 +5,9 @@ README.md
5
5
  Rakefile
6
6
  lib/benchmark/compare.rb
7
7
  lib/benchmark/ips.rb
8
- lib/benchmark/ips/report.rb
9
8
  lib/benchmark/ips/job.rb
9
+ lib/benchmark/ips/job/entry.rb
10
+ lib/benchmark/ips/job/stdout_report.rb
11
+ lib/benchmark/ips/report.rb
10
12
  lib/benchmark/timing.rb
11
13
  test/test_benchmark_ips.rb
data/Rakefile CHANGED
@@ -5,6 +5,7 @@ require 'hoe'
5
5
 
6
6
  Hoe.plugin :minitest
7
7
  Hoe.plugin :git
8
+ Hoe.plugin :ignore
8
9
 
9
10
  hoe = Hoe.spec 'benchmark-ips' do
10
11
  developer('Evan Phoenix', 'evan@phx.io')
@@ -13,7 +13,7 @@ module Benchmark
13
13
  module IPS
14
14
 
15
15
  # Benchmark-ips Gem version.
16
- VERSION = "2.4.0"
16
+ VERSION = "2.4.1"
17
17
 
18
18
  # CODENAME of current version.
19
19
  CODENAME = "Nonlinear Rollercoaster"
@@ -0,0 +1,77 @@
1
+ module Benchmark
2
+ module IPS
3
+ # Benchmark jobs.
4
+ class Job
5
+ # Entries in Benchmark Jobs.
6
+ class Entry
7
+ # Instantiate the Benchmark::IPS::Job::Entry.
8
+ # @param label [#to_s] Label of Benchmarked code.
9
+ # @param action [String, Proc] Code to be benchmarked.
10
+ # @raise [ArgumentError] Raises when action is not String or not responding to +call+.
11
+ def initialize(label, action)
12
+ @label = label
13
+
14
+ if action.kind_of? String
15
+ compile action
16
+ @action = self
17
+ @as_action = true
18
+ else
19
+ unless action.respond_to? :call
20
+ raise ArgumentError, "invalid action, must respond to #call"
21
+ end
22
+
23
+ @action = action
24
+
25
+ if action.respond_to? :arity and action.arity > 0
26
+ @call_loop = true
27
+ else
28
+ @call_loop = false
29
+ end
30
+
31
+ @as_action = false
32
+ end
33
+ end
34
+
35
+ # The label of benchmarking action.
36
+ # @return [#to_s] Label of action.
37
+ attr_reader :label
38
+
39
+ # The benchmarking action.
40
+ # @return [String, Proc] Code to be called, could be String / Proc.
41
+ attr_reader :action
42
+
43
+ # Call action by given times, return if +@call_loop+ is present.
44
+ # @param times [Integer] Times to call +@action+.
45
+ # @return [Integer] Number of times the +@action+ has been called.
46
+ def call_times(times)
47
+ return @action.call(times) if @call_loop
48
+
49
+ act = @action
50
+
51
+ i = 0
52
+ while i < times
53
+ act.call
54
+ i += 1
55
+ end
56
+ end
57
+
58
+ # Compile code into +call_times+ method.
59
+ # @param str [String] Code to be compiled.
60
+ # @return [Symbol] :call_times.
61
+ def compile(str)
62
+ m = (class << self; self; end)
63
+ code = <<-CODE
64
+ def call_times(__total);
65
+ __i = 0
66
+ while __i < __total
67
+ #{str};
68
+ __i += 1
69
+ end
70
+ end
71
+ CODE
72
+ m.class_eval code
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,53 @@
1
+ module Benchmark
2
+ module IPS
3
+ class Job
4
+ class StdoutReport
5
+ def start_warming
6
+ $stdout.puts "Warming up --------------------------------------"
7
+ end
8
+
9
+ def start_running
10
+ $stdout.puts "Calculating -------------------------------------"
11
+ end
12
+
13
+ def warming(label, _warmup)
14
+ $stdout.print rjust(label)
15
+ end
16
+
17
+ def warmup_stats(_warmup_time_us, timing)
18
+ case format
19
+ when :human
20
+ $stdout.printf "%s i/100ms\n", Helpers.scale(timing)
21
+ else
22
+ $stdout.printf "%10d i/100ms\n", timing
23
+ end
24
+ end
25
+
26
+ alias_method :running, :warming
27
+
28
+ def add_report(item, caller)
29
+ $stdout.puts " #{item.body}"
30
+ end
31
+
32
+ private
33
+
34
+ # @return [Symbol] format used for benchmarking
35
+ def format
36
+ Benchmark::IPS.options[:format]
37
+ end
38
+
39
+ # Add padding to label's right if label's length < 20,
40
+ # Otherwise add a new line and 20 whitespaces.
41
+ # @return [String] Right justified label.
42
+ def rjust(label)
43
+ label = label.to_s
44
+ if label.size > 20
45
+ "#{label}\n#{' ' * 20}"
46
+ else
47
+ label.rjust(20)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ 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.0
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Phoenix
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-12 00:00:00.000000000 Z
11
+ date: 2016-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -70,6 +70,8 @@ files:
70
70
  - lib/benchmark/compare.rb
71
71
  - lib/benchmark/ips.rb
72
72
  - lib/benchmark/ips/job.rb
73
+ - lib/benchmark/ips/job/entry.rb
74
+ - lib/benchmark/ips/job/stdout_report.rb
73
75
  - lib/benchmark/ips/report.rb
74
76
  - lib/benchmark/timing.rb
75
77
  - test/test_benchmark_ips.rb