benchmark 0.3.0 → 0.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 +4 -4
- data/.github/workflows/push_gem.yml +46 -0
- data/.github/workflows/test.yml +1 -0
- data/{LICENSE.txt → BSDL} +3 -3
- data/COPYING +56 -0
- data/README.md +1 -1
- data/benchmark.gemspec +2 -0
- data/lib/benchmark.rb +20 -9
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c8a929d80c7226cb317950efed766404d6dff1f921c0c9235ac5c812bed298b
|
4
|
+
data.tar.gz: 2f7a36ecb752ab4505fd7cbf731c8ae3b160972b2b500821e75243e2f7f8b7ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58043fc0c11da02f8abc4fcd0535eee0724d7950e0c593c8079077869c473e1c36a9dfd69b559e8761d1c79fc461f2cb2fcba68d8b3f16e4bdd40a2d1a90cba8
|
7
|
+
data.tar.gz: 9e620a007cb7c9d7beaf15779cf160be1b4726fe49791a229048dd6d1730dba490e7ac1f9f614b9eb466b84eb6140b84634fcaa08c8b4d0c0e5e2176f68f972e
|
@@ -0,0 +1,46 @@
|
|
1
|
+
name: Publish gem to rubygems.org
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
tags:
|
6
|
+
- 'v*'
|
7
|
+
|
8
|
+
permissions:
|
9
|
+
contents: read
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
push:
|
13
|
+
if: github.repository == 'ruby/benchmark'
|
14
|
+
runs-on: ubuntu-latest
|
15
|
+
|
16
|
+
environment:
|
17
|
+
name: rubygems.org
|
18
|
+
url: https://rubygems.org/gems/benchmark
|
19
|
+
|
20
|
+
permissions:
|
21
|
+
contents: write
|
22
|
+
id-token: write
|
23
|
+
|
24
|
+
steps:
|
25
|
+
- name: Harden Runner
|
26
|
+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
|
27
|
+
with:
|
28
|
+
egress-policy: audit
|
29
|
+
|
30
|
+
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
|
31
|
+
|
32
|
+
- name: Set up Ruby
|
33
|
+
uses: ruby/setup-ruby@a6e6f86333f0a2523ece813039b8b4be04560854 # v1.190.0
|
34
|
+
with:
|
35
|
+
bundler-cache: true
|
36
|
+
ruby-version: ruby
|
37
|
+
|
38
|
+
- name: Publish to RubyGems
|
39
|
+
uses: rubygems/release-gem@a25424ba2ba8b387abc8ef40807c2c85b96cbe32 # v1.1.1
|
40
|
+
|
41
|
+
- name: Create GitHub release
|
42
|
+
run: |
|
43
|
+
tag_name="$(git describe --tags --abbrev=0)"
|
44
|
+
gh release create "${tag_name}" --verify-tag --generate-notes
|
45
|
+
env:
|
46
|
+
GITHUB_TOKEN: ${{ secrets.MATZBOT_GITHUB_WORKFLOW_TOKEN }}
|
data/.github/workflows/test.yml
CHANGED
@@ -16,6 +16,7 @@ jobs:
|
|
16
16
|
ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
|
17
17
|
os: [ ubuntu-latest, macos-latest, windows-latest ]
|
18
18
|
exclude:
|
19
|
+
- { os: macos-latest, ruby: 2.5 }
|
19
20
|
- { os: windows-latest, ruby: truffleruby-head }
|
20
21
|
- { os: windows-latest, ruby: truffleruby }
|
21
22
|
runs-on: ${{ matrix.os }}
|
data/{LICENSE.txt → BSDL}
RENAMED
@@ -4,10 +4,10 @@ Redistribution and use in source and binary forms, with or without
|
|
4
4
|
modification, are permitted provided that the following conditions
|
5
5
|
are met:
|
6
6
|
1. Redistributions of source code must retain the above copyright
|
7
|
-
notice, this list of conditions and the following disclaimer.
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
8
8
|
2. Redistributions in binary form must reproduce the above copyright
|
9
|
-
notice, this list of conditions and the following disclaimer in the
|
10
|
-
documentation and/or other materials provided with the distribution.
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
10
|
+
documentation and/or other materials provided with the distribution.
|
11
11
|
|
12
12
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
13
13
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
data/COPYING
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
|
2
|
+
You can redistribute it and/or modify it under either the terms of the
|
3
|
+
2-clause BSDL (see the file BSDL), or the conditions below:
|
4
|
+
|
5
|
+
1. You may make and give away verbatim copies of the source form of the
|
6
|
+
software without restriction, provided that you duplicate all of the
|
7
|
+
original copyright notices and associated disclaimers.
|
8
|
+
|
9
|
+
2. You may modify your copy of the software in any way, provided that
|
10
|
+
you do at least ONE of the following:
|
11
|
+
|
12
|
+
a. place your modifications in the Public Domain or otherwise
|
13
|
+
make them Freely Available, such as by posting said
|
14
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
15
|
+
the author to include your modifications in the software.
|
16
|
+
|
17
|
+
b. use the modified software only within your corporation or
|
18
|
+
organization.
|
19
|
+
|
20
|
+
c. give non-standard binaries non-standard names, with
|
21
|
+
instructions on where to get the original software distribution.
|
22
|
+
|
23
|
+
d. make other distribution arrangements with the author.
|
24
|
+
|
25
|
+
3. You may distribute the software in object code or binary form,
|
26
|
+
provided that you do at least ONE of the following:
|
27
|
+
|
28
|
+
a. distribute the binaries and library files of the software,
|
29
|
+
together with instructions (in the manual page or equivalent)
|
30
|
+
on where to get the original distribution.
|
31
|
+
|
32
|
+
b. accompany the distribution with the machine-readable source of
|
33
|
+
the software.
|
34
|
+
|
35
|
+
c. give non-standard binaries non-standard names, with
|
36
|
+
instructions on where to get the original software distribution.
|
37
|
+
|
38
|
+
d. make other distribution arrangements with the author.
|
39
|
+
|
40
|
+
4. You may modify and include the part of the software into any other
|
41
|
+
software (possibly commercial). But some files in the distribution
|
42
|
+
are not written by the author, so that they are not under these terms.
|
43
|
+
|
44
|
+
For the list of those files and their copying conditions, see the
|
45
|
+
file LEGAL.
|
46
|
+
|
47
|
+
5. The scripts and library files supplied as input to or produced as
|
48
|
+
output from the software do not automatically fall under the
|
49
|
+
copyright of the software, but belong to whomever generated them,
|
50
|
+
and may be sold commercially, and may be aggregated with this
|
51
|
+
software.
|
52
|
+
|
53
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
54
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
55
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
56
|
+
PURPOSE.
|
data/README.md
CHANGED
@@ -35,7 +35,7 @@ On my machine (OSX 10.8.3 on i5 1.7 GHz) this generates:
|
|
35
35
|
0.350000 0.400000 0.750000 ( 0.835234)
|
36
36
|
```
|
37
37
|
|
38
|
-
This report shows the user CPU time, system CPU time, the sum of
|
38
|
+
This report shows the user CPU time, system CPU time, the total time (sum of user CPU time, system CPU time, children's user CPU time, and children's system CPU time), and the elapsed real time. The unit of time is seconds.
|
39
39
|
|
40
40
|
Do some experiments sequentially using the #bm method:
|
41
41
|
|
data/benchmark.gemspec
CHANGED
@@ -16,6 +16,8 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.homepage = "https://github.com/ruby/benchmark"
|
17
17
|
spec.licenses = ["Ruby", "BSD-2-Clause"]
|
18
18
|
|
19
|
+
spec.required_ruby_version = ">= 2.1.0"
|
20
|
+
|
19
21
|
spec.metadata["homepage_uri"] = spec.homepage
|
20
22
|
spec.metadata["source_code_uri"] = spec.homepage
|
21
23
|
|
data/lib/benchmark.rb
CHANGED
@@ -30,8 +30,9 @@
|
|
30
30
|
#
|
31
31
|
# 0.350000 0.400000 0.750000 ( 0.835234)
|
32
32
|
#
|
33
|
-
# This report shows the user CPU time, system CPU time, the
|
34
|
-
#
|
33
|
+
# This report shows the user CPU time, system CPU time, the total time
|
34
|
+
# (sum of user CPU time, system CPU time, children's user CPU time,
|
35
|
+
# and children's system CPU time), and the elapsed real time. The unit
|
35
36
|
# of time is seconds.
|
36
37
|
#
|
37
38
|
# * Do some experiments sequentially using the #bm method:
|
@@ -121,7 +122,7 @@
|
|
121
122
|
|
122
123
|
module Benchmark
|
123
124
|
|
124
|
-
VERSION = "0.
|
125
|
+
VERSION = "0.4.1"
|
125
126
|
|
126
127
|
BENCHMARK_VERSION = "2002-04-25" # :nodoc:
|
127
128
|
|
@@ -173,9 +174,15 @@ module Benchmark
|
|
173
174
|
label_width ||= 0
|
174
175
|
label_width += 1
|
175
176
|
format ||= FORMAT
|
176
|
-
print ' '*label_width + caption unless caption.empty?
|
177
177
|
report = Report.new(label_width, format)
|
178
178
|
results = yield(report)
|
179
|
+
|
180
|
+
print " " * report.width + caption unless caption.empty?
|
181
|
+
report.list.each { |i|
|
182
|
+
print i.label.to_s.ljust(report.width)
|
183
|
+
print i.format(report.format, *format)
|
184
|
+
}
|
185
|
+
|
179
186
|
Array === results and results.grep(Tms).each {|t|
|
180
187
|
print((labels.shift || t.label || "").ljust(label_width), t.format(format))
|
181
188
|
}
|
@@ -307,6 +314,10 @@ module Benchmark
|
|
307
314
|
|
308
315
|
#
|
309
316
|
# Returns the elapsed real time used to execute the given block.
|
317
|
+
# The unit of time is seconds.
|
318
|
+
#
|
319
|
+
# Benchmark.realtime { "a" * 1_000_000_000 }
|
320
|
+
# #=> 0.5098029999935534
|
310
321
|
#
|
311
322
|
def realtime # :yield:
|
312
323
|
r0 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
@@ -376,16 +387,16 @@ module Benchmark
|
|
376
387
|
# formatting rules.
|
377
388
|
#
|
378
389
|
def item(label = "", *format, &blk) # :yield:
|
379
|
-
|
390
|
+
w = label.to_s.length
|
391
|
+
@width = w if @width < w
|
380
392
|
@list << res = Benchmark.measure(label, &blk)
|
381
|
-
print res.format(@format, *format)
|
382
393
|
res
|
383
394
|
end
|
384
395
|
|
385
396
|
alias report item
|
386
397
|
|
387
398
|
# An array of Benchmark::Tms objects representing each item.
|
388
|
-
attr_reader :list
|
399
|
+
attr_reader :width, :format, :list
|
389
400
|
end
|
390
401
|
|
391
402
|
|
@@ -493,7 +504,7 @@ module Benchmark
|
|
493
504
|
# accepts the following extensions:
|
494
505
|
#
|
495
506
|
# <tt>%u</tt>:: Replaced by the user CPU time, as reported by Tms#utime.
|
496
|
-
# <tt>%y</tt>:: Replaced by the system CPU time, as reported by #stime (Mnemonic: y of "s*y*stem")
|
507
|
+
# <tt>%y</tt>:: Replaced by the system CPU time, as reported by Tms#stime (Mnemonic: y of "s*y*stem")
|
497
508
|
# <tt>%U</tt>:: Replaced by the children's user CPU time, as reported by Tms#cutime
|
498
509
|
# <tt>%Y</tt>:: Replaced by the children's system CPU time, as reported by Tms#cstime
|
499
510
|
# <tt>%t</tt>:: Replaced by the total CPU time, as reported by Tms#total
|
@@ -501,7 +512,7 @@ module Benchmark
|
|
501
512
|
# <tt>%n</tt>:: Replaced by the label string, as reported by Tms#label (Mnemonic: n of "*n*ame")
|
502
513
|
#
|
503
514
|
# If +format+ is not given, FORMAT is used as default value, detailing the
|
504
|
-
# user, system and real elapsed time.
|
515
|
+
# user, system, total and real elapsed time.
|
505
516
|
#
|
506
517
|
def format(format = nil, *args)
|
507
518
|
str = (format || FORMAT).dup
|
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.4.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: 2025-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: a performance benchmarking library
|
14
14
|
email:
|
@@ -18,10 +18,12 @@ extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
20
|
- ".github/dependabot.yml"
|
21
|
+
- ".github/workflows/push_gem.yml"
|
21
22
|
- ".github/workflows/test.yml"
|
22
23
|
- ".gitignore"
|
24
|
+
- BSDL
|
25
|
+
- COPYING
|
23
26
|
- Gemfile
|
24
|
-
- LICENSE.txt
|
25
27
|
- README.md
|
26
28
|
- Rakefile
|
27
29
|
- benchmark.gemspec
|
@@ -43,14 +45,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
43
45
|
requirements:
|
44
46
|
- - ">="
|
45
47
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
48
|
+
version: 2.1.0
|
47
49
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
50
|
requirements:
|
49
51
|
- - ">="
|
50
52
|
- !ruby/object:Gem::Version
|
51
53
|
version: '0'
|
52
54
|
requirements: []
|
53
|
-
rubygems_version: 3.5.
|
55
|
+
rubygems_version: 3.5.11
|
54
56
|
signing_key:
|
55
57
|
specification_version: 4
|
56
58
|
summary: a performance benchmarking library
|