benchmarker 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGES.md +9 -0
- data/MIT-LICENSE +20 -0
- data/README.md +26 -0
- data/Rakefile +107 -0
- data/benchmarker.gemspec +20 -34
- data/lib/benchmarker.rb +1041 -0
- data/test/benchmarker_test.rb +1532 -560
- metadata +53 -79
- data/CHANGES.txt +0 -6
- data/examples/bench_loop.rb +0 -51
- data/examples/bench_require.rb +0 -34
- data/test/oktest.rb +0 -825
metadata
CHANGED
@@ -1,94 +1,68 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: benchmarker
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 0
|
10
|
-
version: 0.1.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
13
|
-
-
|
14
|
-
autorequire:
|
6
|
+
authors:
|
7
|
+
- kwatch
|
8
|
+
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
11
|
+
date: 2021-11-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: oktest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
22
27
|
description: |
|
23
|
-
Benchmarker is a
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
require 'rubygems'
|
28
|
-
require 'benchmarker'
|
29
|
-
|
30
|
-
Benchmarker.new(:width=>20, :loop=>100*1000, :cycle=>5, :extra=>1) do |bm|
|
31
|
-
range = 1..1000
|
32
|
-
bm.task("each") do
|
33
|
-
arr = []
|
34
|
-
range.each {|n| arr << n }
|
35
|
-
end
|
36
|
-
bm.task("collect") do
|
37
|
-
arr = range.collect {|n| n }
|
38
|
-
end
|
39
|
-
bm.task("inject") do
|
40
|
-
arr = range.inject([]) {|a, n| a << n; a }
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
email: kwa(at)kuwata-lab.com
|
28
|
+
Benchmarker is a pretty good benchmark tool for Ruby.
|
29
|
+
Compared to `benchmark.rb` (standard library), Benchmarker has a lot of useful features.
|
30
|
+
See: https://kwatch.github.io/benchmarker/ruby.html
|
31
|
+
email: kwatch@gmail.com
|
45
32
|
executables: []
|
46
|
-
|
47
33
|
extensions: []
|
48
|
-
|
49
34
|
extra_rdoc_files: []
|
50
|
-
|
51
|
-
|
52
|
-
-
|
53
|
-
-
|
54
|
-
-
|
55
|
-
- examples/bench_require.rb
|
56
|
-
- CHANGES.txt
|
57
|
-
- setup.rb
|
35
|
+
files:
|
36
|
+
- CHANGES.md
|
37
|
+
- MIT-LICENSE
|
38
|
+
- README.md
|
39
|
+
- Rakefile
|
58
40
|
- benchmarker.gemspec
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
41
|
+
- lib/benchmarker.rb
|
42
|
+
- setup.rb
|
43
|
+
- test/benchmarker_test.rb
|
44
|
+
homepage: https://kwatch.github.io/benchmarker/ruby.html
|
45
|
+
licenses:
|
46
|
+
- MIT
|
47
|
+
metadata: {}
|
48
|
+
post_install_message:
|
64
49
|
rdoc_options: []
|
65
|
-
|
66
|
-
require_paths:
|
50
|
+
require_paths:
|
67
51
|
- lib
|
68
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
-
|
70
|
-
requirements:
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
71
54
|
- - ">="
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
version: "0"
|
77
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
-
none: false
|
79
|
-
requirements:
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '2.0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
80
59
|
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
|
83
|
-
segments:
|
84
|
-
- 0
|
85
|
-
version: "0"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
86
62
|
requirements: []
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
summary: a small utility for benchmarking
|
93
|
-
test_files:
|
63
|
+
rubygems_version: 3.2.22
|
64
|
+
signing_key:
|
65
|
+
specification_version: 4
|
66
|
+
summary: pretty good benchmark library
|
67
|
+
test_files:
|
94
68
|
- test/benchmarker_test.rb
|
data/CHANGES.txt
DELETED
data/examples/bench_loop.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
###
|
2
|
-
### benchmark to compare loop methods
|
3
|
-
###
|
4
|
-
|
5
|
-
require 'benchmarker'
|
6
|
-
|
7
|
-
nums = (1..10000).to_a #.shuffle
|
8
|
-
|
9
|
-
Benchmarker.new(:width=>24, :loop=>1000, :cycle=>5, :extra=>1) do |bm|
|
10
|
-
|
11
|
-
bm.empty_task do
|
12
|
-
nil
|
13
|
-
end
|
14
|
-
|
15
|
-
bm.task("each() & '+='") do
|
16
|
-
total = 0
|
17
|
-
nums.each {|n| total += n }
|
18
|
-
total
|
19
|
-
end
|
20
|
-
|
21
|
-
bm.task("inject()") do
|
22
|
-
total = nums.inject(0) {|t, n| t += n }
|
23
|
-
total
|
24
|
-
end
|
25
|
-
|
26
|
-
msg = " # skip because Symbol#to_proc() is not defined."
|
27
|
-
msg = nil if :+.respond_to?(:to_proc)
|
28
|
-
bm.task("inject(&:+)", :skip=>msg) do
|
29
|
-
total = nums.inject(0, &:+)
|
30
|
-
total
|
31
|
-
end
|
32
|
-
|
33
|
-
bm.task("for statement") do
|
34
|
-
total = 0
|
35
|
-
for n in nums
|
36
|
-
total += n
|
37
|
-
end
|
38
|
-
total
|
39
|
-
end
|
40
|
-
|
41
|
-
bm.task("while statement") do
|
42
|
-
i, len = 0, nums.length
|
43
|
-
total = 0
|
44
|
-
while i < len
|
45
|
-
total += nums[i]
|
46
|
-
i += 1
|
47
|
-
end
|
48
|
-
total
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
data/examples/bench_require.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
###
|
2
|
-
### benchmarks to measure library loading times.
|
3
|
-
###
|
4
|
-
|
5
|
-
|
6
|
-
require 'benchmarker'
|
7
|
-
|
8
|
-
targets = %w[cgi cgi/session erb tempfile tmpdir openssl
|
9
|
-
logger pathname pstore time date2 uri drb fileutils
|
10
|
-
rss rexml/document yaml psych json rubygems]
|
11
|
-
|
12
|
-
if RUBY_VERSION >= '1.9'
|
13
|
-
targets.delete('date2')
|
14
|
-
elsif RUBY_VERSION < '1.9'
|
15
|
-
targets.delete('psych')
|
16
|
-
targets.delete('json')
|
17
|
-
end
|
18
|
-
|
19
|
-
loop = 10
|
20
|
-
cycle = 1 # or 5
|
21
|
-
Benchmarker.new(:loop=>loop, :cycle=>cycle, :extra=>1) do |bm|
|
22
|
-
|
23
|
-
#bm.empty_task "(Empty) ruby" do
|
24
|
-
bm.task "ruby" do
|
25
|
-
system "ruby -e nil"
|
26
|
-
end
|
27
|
-
|
28
|
-
targets.each do |lib|
|
29
|
-
bm.task "ruby -r #{lib}" do
|
30
|
-
system "ruby -r #{lib} -e nil"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|