benchmarker 0.1.0 → 1.0.0
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 +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
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b4db8de6cac8784ee9b81df579b14f1cefc4b00435e552f15daf20b80d9ec4d6
|
4
|
+
data.tar.gz: eebde6574d665a1db773ba96a246813594e3b2c169dfc3a425c084bc40a13a26
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 22c6df70a7b7dcbc27012a6b698106d170346c4c58e1bd8d16d194b05a94105b16fa7cb1e72d38c5cea20ae1a8dc07ef7dd1fa3b547a992cffe5a9a646ed6a70
|
7
|
+
data.tar.gz: 82f38ebb748596137984a4aa59cccb7f115bfd191e166cf8a72722fd3dcb073ee867d2b6aca540e465d387fc38018524d73b7804088d8725f7c3d9d45d864026
|
data/CHANGES.md
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2010-2021 kuwata-lab.com all rights reserved
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Benchamrker.rb README
|
2
|
+
=====================
|
3
|
+
|
4
|
+
Benchmarker.rb is an awesome benchmarking tool for Ruby.
|
5
|
+
|
6
|
+
* Easy to use
|
7
|
+
* Pretty good output (including JSON format)
|
8
|
+
* Rich features compared to ``benchmark.rb`` (standard library)
|
9
|
+
* Iterate benchmarks and calculate average of resutls (optional)
|
10
|
+
* Remove min and max results to exclude abnormal values (optional)
|
11
|
+
* Remove loop times from each benchmark results (optional)
|
12
|
+
* Save benchmark results into JSON file (optional)
|
13
|
+
* Change loop times, number of iteration, etc by command-line option
|
14
|
+
* Print platform information automatically
|
15
|
+
* Print ranking graph and ratio matrix automatically
|
16
|
+
|
17
|
+
See <https://kwatch.github.io/benchmarker/> for details.
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
License and Copyright
|
22
|
+
---------------------
|
23
|
+
|
24
|
+
$License: MIT License $
|
25
|
+
|
26
|
+
$Copyright: copyright(c) 2010-2021 kuwata-lab.com all rights reserved $
|
data/Rakefile
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
project = "benchmarker"
|
3
|
+
release = "$Release: 1.0.0 $".split()[1]
|
4
|
+
copyright = "copyright(c) 2010-2021 kuwata-lab.com all rights reserved"
|
5
|
+
license = "MIT License"
|
6
|
+
|
7
|
+
require 'fileutils'
|
8
|
+
include FileUtils
|
9
|
+
|
10
|
+
require 'rake/clean'
|
11
|
+
CLEAN.include("build/#{project}-#{release}")
|
12
|
+
CLOBBER.include("build")
|
13
|
+
|
14
|
+
|
15
|
+
task :default => :test
|
16
|
+
|
17
|
+
def _do_test(ruby="ruby")
|
18
|
+
sh "#{ruby} -r oktest -e 'Oktest.main' -- test -sc"
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "do test"
|
22
|
+
task :test do
|
23
|
+
_do_test("ruby")
|
24
|
+
end
|
25
|
+
|
26
|
+
ruby_vers = %w[2.0.0-p648 2.1.10 2.2.10 2.3.8 2.4.10 2.5.8 2.6.2 2.7.1 3.0.2]
|
27
|
+
|
28
|
+
desc "do test on multiple ruby versions"
|
29
|
+
task :'test:all' do
|
30
|
+
ruby_vers.each do |ruby_ver|
|
31
|
+
puts "========== ruby #{ruby_ver} =========="
|
32
|
+
ruby = "#{ENV['VS_HOME']}/ruby/#{ruby_ver}/bin/ruby"
|
33
|
+
_do_test(ruby)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
def copy_into(*args)
|
39
|
+
args = args.flatten
|
40
|
+
dir = args.pop
|
41
|
+
mkdir_p dir unless File.exists?(dir)
|
42
|
+
cp_r args, dir
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
def edit_files(*filenames, &block)
|
47
|
+
filenames.flatten.each do |fname|
|
48
|
+
Dir.glob(fname).each do |fpath|
|
49
|
+
next unless File.file?(fpath)
|
50
|
+
s = File.open(fpath, 'rb') {|f| f.read() }
|
51
|
+
s = block.arity == 2 ? yield(s, fpath) : yield(s)
|
52
|
+
File.open(fpath, 'wb') {|f| f.write(s) }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
desc "create 'build/#{project}-#{release}/' and copy files to it"
|
59
|
+
task :build do
|
60
|
+
release = ENV['rel'] or
|
61
|
+
raise "rake: requires 'rel=X.X.X'"
|
62
|
+
dir = "build/#{project}-#{release}"
|
63
|
+
#rm_rf dir if File.exist?(dir)
|
64
|
+
fnames = Dir.glob("#{dir}*")
|
65
|
+
rm_rf fnames unless fnames.empty?
|
66
|
+
mkdir_p dir
|
67
|
+
## store
|
68
|
+
cp_r %W[README.md CHANGES.md Rakefile MIT-LICENSE #{project}.gemspec setup.rb], dir
|
69
|
+
copy_into Dir.glob("lib/*.rb"), "#{dir}/lib"
|
70
|
+
copy_into Dir.glob("test/*test.rb"), "#{dir}/test"
|
71
|
+
#copy_into Dir.glob("examples/*.rb"), "#{dir}/examples"
|
72
|
+
## edit
|
73
|
+
edit_files("#{dir}/**/*") do |content, filename|
|
74
|
+
if ! %w[setup.rb].include?(File.basename(filename))
|
75
|
+
content.gsub! /[\$]Release:.*?\$/, "$""Release: #{release} $"
|
76
|
+
content.gsub! /[\$]Copyright:.*?\$/, "$""Copyright: #{copyright} $"
|
77
|
+
content.gsub! /[\$]License:.*?\$/, "$""License: #{license} $"
|
78
|
+
content.gsub! /[\$]Release\$/, release
|
79
|
+
content.gsub! /[\$]Copyright\$/, copyright
|
80
|
+
content.gsub! /[\$]License\$/, license
|
81
|
+
end
|
82
|
+
content
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
desc "create gem package"
|
88
|
+
task :package => :build do
|
89
|
+
release = ENV['rel'] or
|
90
|
+
raise "rake package: requires 'rel=X.X.X'"
|
91
|
+
base = "#{project}-#{release}"
|
92
|
+
#chdir "build" do
|
93
|
+
# sh "tar cf #{base}.tar.gz #{base}"
|
94
|
+
#end
|
95
|
+
chdir "build/#{base}" do
|
96
|
+
sh "gem build #{project}.gemspec"
|
97
|
+
mv Dir.glob("#{project}-*.gem"), ".."
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
desc "upload gem package"
|
102
|
+
task :publish do
|
103
|
+
release = ENV['rel'] or
|
104
|
+
raise "rake publish: requires 'rel=X.X.X'"
|
105
|
+
gem = "build/#{project}-#{release}"
|
106
|
+
sh "gem push #{gem}"
|
107
|
+
end
|
data/benchmarker.gemspec
CHANGED
@@ -1,57 +1,43 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
|
3
3
|
###
|
4
|
-
### $Release:
|
5
|
-
### $Copyright: copyright(c) 2010-
|
6
|
-
### $License:
|
4
|
+
### $Release: 1.0.0 $
|
5
|
+
### $Copyright: copyright(c) 2010-2021 kuwata-lab.com all rights reserved $
|
6
|
+
### $License: MIT License $
|
7
7
|
###
|
8
8
|
|
9
9
|
require 'rubygems'
|
10
10
|
|
11
11
|
spec = Gem::Specification.new do |s|
|
12
|
-
## package information
|
13
12
|
s.name = "benchmarker"
|
14
|
-
s.author = "
|
15
|
-
s.email = "
|
16
|
-
s.rubyforge_project = 'benchmarker'
|
17
|
-
s.version = "$Release:
|
13
|
+
s.author = "kwatch"
|
14
|
+
s.email = "kwatch@gmail.com"
|
15
|
+
#s.rubyforge_project = 'benchmarker'
|
16
|
+
s.version = "$Release: 1.0.0 $".split()[1]
|
18
17
|
s.platform = Gem::Platform::RUBY
|
19
|
-
|
20
|
-
s.
|
21
|
-
s.
|
18
|
+
s.license = 'MIT'
|
19
|
+
#s.license = 'CC-PDDC' # public domain
|
20
|
+
#s.homepage = "https://github.com/kwatch/benchmarker/"
|
21
|
+
s.homepage = "https://kwatch.github.io/benchmarker/ruby.html"
|
22
|
+
s.summary = "pretty good benchmark library"
|
22
23
|
s.description = <<-'END'
|
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
|
24
|
+
Benchmarker is a pretty good benchmark tool for Ruby.
|
25
|
+
Compared to `benchmark.rb` (standard library), Benchmarker has a lot of useful features.
|
26
|
+
See: https://kwatch.github.io/benchmarker/ruby.html
|
43
27
|
END
|
44
28
|
|
45
29
|
## files
|
46
30
|
files = [
|
47
|
-
'benchmarker.rb',
|
31
|
+
'lib/benchmarker.rb',
|
48
32
|
'test/**/*',
|
49
|
-
'examples/**/*',
|
50
|
-
'
|
33
|
+
#'examples/**/*',
|
34
|
+
'README.md', 'CHANGES.md', 'Rakefile', 'MIT-LICENSE',
|
51
35
|
'setup.rb', 'benchmarker.gemspec',
|
52
36
|
]
|
53
37
|
s.files = files.collect {|pat| Dir.glob(pat) }.flatten
|
54
38
|
s.test_file = 'test/benchmarker_test.rb'
|
39
|
+
s.required_ruby_version = '>= 2.0'
|
40
|
+
s.add_development_dependency "oktest", '~> 1.0'
|
55
41
|
end
|
56
42
|
|
57
43
|
# Quick fix for Ruby 1.8.3 / YAML bug (thanks to Ross Bamford)
|