benchmark 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aef3b10579784cec3e456e8dad6823cd6792c3ce812150bbcb59c99841d7ddcb
4
- data.tar.gz: eed95c5b6a81080da3c9c8bd3300e0227e87915b3b95297eaf7b26362e7a2666
3
+ metadata.gz: eafbbb0ec7f26fb0f60f21a677e4f749670e912c9ff1948fec84aa0b6f8a08bd
4
+ data.tar.gz: 32098b08dfca91b193cd47d3a009287afc4dabb36a093e8398998e78dcbcf2b3
5
5
  SHA512:
6
- metadata.gz: 65194567777f919d9d373226787add8199f40001ee43cfa16ea3a8b0a7a428ba5a1c128429e464e398afb52e96706155f574dbb9e9be299de4a8c35ad4ee63e5
7
- data.tar.gz: 3fc948af4d9a4a3ac54de2c1310b929a643ea32ceacedca6c3a8074a0e5a4f1a2cd35089f6e2029ec956c28e4a351993d1933c6955398cc9a003b9e3520efae9
6
+ metadata.gz: 2abb831bd071d73f72efe77b45ed4eca4eb861c124bdf976e6fb498e2c44edb7fbed91b4b4063a7a27f1c8652e8c365d45792ffc843d08925f50a564742c6832
7
+ data.tar.gz: 8b46138b50800e8ef91417763c238e0cb1ab55f863fa491d92c932a8aa13168065cf19f22de3ed79b5c580728647da3904b423c6de463d775d489d6960f032a0
@@ -0,0 +1,22 @@
1
+ name: build
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ name: build (${{ matrix.ruby }} / ${{ matrix.os }})
8
+ strategy:
9
+ matrix:
10
+ ruby: [ '3.0', 2.7, 2.6, 2.5, head ]
11
+ os: [ ubuntu-latest, macos-latest ]
12
+ runs-on: ${{ matrix.os }}
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - name: Set up Ruby
16
+ uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: ${{ matrix.ruby }}
19
+ - name: Install dependencies
20
+ run: bundle install
21
+ - name: Run test
22
+ run: rake test
data/benchmark.gemspec CHANGED
@@ -24,6 +24,6 @@ Gem::Specification.new do |spec|
24
24
  `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
25
  end
26
26
  spec.bindir = "exe"
27
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.executables = []
28
28
  spec.require_paths = ["lib"]
29
29
  end
@@ -1,3 +1,3 @@
1
1
  module Benchmark
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/benchmark.rb CHANGED
@@ -128,6 +128,9 @@ module Benchmark
128
128
  # benchmark tests. Reserves +label_width+ leading spaces for
129
129
  # labels on each line. Prints +caption+ at the top of the
130
130
  # report, and uses +format+ to format each line.
131
+ # (Note: +caption+ must contain a terminating newline character,
132
+ # see the default Benchmark::Tms::CAPTION for an example.)
133
+ #
131
134
  # Returns an array of Benchmark::Tms objects.
132
135
  #
133
136
  # If the block returns an array of
@@ -163,8 +166,8 @@ module Benchmark
163
166
  #
164
167
 
165
168
  def benchmark(caption = "", label_width = nil, format = nil, *labels) # :yield: report
166
- sync = STDOUT.sync
167
- STDOUT.sync = true
169
+ sync = $stdout.sync
170
+ $stdout.sync = true
168
171
  label_width ||= 0
169
172
  label_width += 1
170
173
  format ||= FORMAT
@@ -176,7 +179,7 @@ module Benchmark
176
179
  }
177
180
  report.list
178
181
  ensure
179
- STDOUT.sync = sync unless sync.nil?
182
+ $stdout.sync = sync unless sync.nil?
180
183
  end
181
184
 
182
185
 
@@ -247,8 +250,8 @@ module Benchmark
247
250
  job = Job.new(width)
248
251
  yield(job)
249
252
  width = job.width + 1
250
- sync = STDOUT.sync
251
- STDOUT.sync = true
253
+ sync = $stdout.sync
254
+ $stdout.sync = true
252
255
 
253
256
  # rehearsal
254
257
  puts 'Rehearsal '.ljust(width+CAPTION.length,'-')
@@ -268,7 +271,7 @@ module Benchmark
268
271
  Benchmark.measure(label, &item).tap { |res| print res }
269
272
  }
270
273
  ensure
271
- STDOUT.sync = sync unless sync.nil?
274
+ $stdout.sync = sync unless sync.nil?
272
275
  end
273
276
 
274
277
  #
@@ -527,6 +530,20 @@ module Benchmark
527
530
  [@label, @utime, @stime, @cutime, @cstime, @real]
528
531
  end
529
532
 
533
+ #
534
+ # Returns a hash containing the same data as `to_a`.
535
+ #
536
+ def to_h
537
+ {
538
+ label: @label,
539
+ utime: @utime,
540
+ stime: @stime,
541
+ cutime: @cutime,
542
+ cstime: @cstime,
543
+ real: @real
544
+ }
545
+ end
546
+
530
547
  protected
531
548
 
532
549
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: benchmark
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yukihiro Matsumoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-22 00:00:00.000000000 Z
11
+ date: 2021-10-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: a performance benchmarking library
14
14
  email:
@@ -17,8 +17,8 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - ".github/workflows/test.yml"
20
21
  - ".gitignore"
21
- - ".travis.yml"
22
22
  - Gemfile
23
23
  - LICENSE.txt
24
24
  - README.md
@@ -50,7 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
50
  - !ruby/object:Gem::Version
51
51
  version: '0'
52
52
  requirements: []
53
- rubygems_version: 3.2.2
53
+ rubygems_version: 3.3.0.dev
54
54
  signing_key:
55
55
  specification_version: 4
56
56
  summary: a performance benchmarking library
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
- rvm:
4
- - 2.6.3
5
- - ruby-head
6
- script: rake test