benchmark 0.1.1 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/test.yml +32 -0
- data/benchmark.gemspec +1 -1
- data/lib/benchmark/version.rb +2 -1
- data/lib/benchmark.rb +23 -6
- metadata +5 -4
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 339cfd7a84785395325c784c70f63d2a2498db52ed3f6eb8594430fb055d78d0
|
4
|
+
data.tar.gz: 790460db2a1df4545ba7df64f5f72dd24966d91ce1107077027c13d85208b1fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f29b45297e09c3b2d456df69741bc95b8e04227f96a4b424fec615e63c93c9086ad6fb4b11b90b2ee9abdd5f6a1b468c268302a51952618a7cfd14c1bbe85f1
|
7
|
+
data.tar.gz: 1fc4e6e367546dce779f8273161f400cf974c6891563f02ce7e6e36fb8f3a121678f532e3172b3fdc3687b03047250dcabd26deb692098342b6c27677a1e60b9
|
@@ -0,0 +1,32 @@
|
|
1
|
+
name: test
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
ruby-versions:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
outputs:
|
9
|
+
versions: ${{ steps.versions.outputs.value }}
|
10
|
+
steps:
|
11
|
+
- id: versions
|
12
|
+
run: |
|
13
|
+
versions=$(curl -s 'https://cache.ruby-lang.org/pub/misc/ci_versions/all.json' | jq -c '. + ["2.5"]')
|
14
|
+
echo "::set-output name=value::${versions}"
|
15
|
+
test:
|
16
|
+
needs: ruby-versions
|
17
|
+
name: build (${{ matrix.ruby }} / ${{ matrix.os }})
|
18
|
+
strategy:
|
19
|
+
matrix:
|
20
|
+
ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
|
21
|
+
os: [ ubuntu-latest, macos-latest ]
|
22
|
+
runs-on: ${{ matrix.os }}
|
23
|
+
steps:
|
24
|
+
- uses: actions/checkout@v3
|
25
|
+
- name: Set up Ruby
|
26
|
+
uses: ruby/setup-ruby@v1
|
27
|
+
with:
|
28
|
+
ruby-version: ${{ matrix.ruby }}
|
29
|
+
- name: Install dependencies
|
30
|
+
run: bundle install
|
31
|
+
- name: Run test
|
32
|
+
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 =
|
27
|
+
spec.executables = []
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
end
|
data/lib/benchmark/version.rb
CHANGED
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 =
|
167
|
-
|
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
|
-
|
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 =
|
251
|
-
|
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
|
-
|
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.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yukihiro Matsumoto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: a performance benchmarking library
|
14
14
|
email:
|
@@ -17,8 +17,9 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
+
- ".github/dependabot.yml"
|
21
|
+
- ".github/workflows/test.yml"
|
20
22
|
- ".gitignore"
|
21
|
-
- ".travis.yml"
|
22
23
|
- Gemfile
|
23
24
|
- LICENSE.txt
|
24
25
|
- README.md
|
@@ -50,7 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
51
|
- !ruby/object:Gem::Version
|
51
52
|
version: '0'
|
52
53
|
requirements: []
|
53
|
-
rubygems_version: 3.
|
54
|
+
rubygems_version: 3.4.0.dev
|
54
55
|
signing_key:
|
55
56
|
specification_version: 4
|
56
57
|
summary: a performance benchmarking library
|