somebee-rbench 0.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.
- data/LICENSE +20 -0
- data/README +103 -0
- data/Rakefile +9 -0
- data/TODO +6 -0
- data/lib/rbench.rb +16 -0
- metadata +59 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Yehuda Katz & Sindre Aarsaether
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
rbench
|
2
|
+
======
|
3
|
+
|
4
|
+
== What is RBench?
|
5
|
+
|
6
|
+
Library for generating nice ruby-benchmarks in several formats.
|
7
|
+
Only text-output is available atm.
|
8
|
+
|
9
|
+
Heavily inspired by benchwarmer. Much love.
|
10
|
+
|
11
|
+
== Usage
|
12
|
+
|
13
|
+
require "rubygems"
|
14
|
+
require "rbench"
|
15
|
+
|
16
|
+
# Choose how many times you want to repeat each benchmark.
|
17
|
+
# This can be overridden on specific reports, if needed.
|
18
|
+
TIMES = 100_000
|
19
|
+
|
20
|
+
# A relatively simple benchmark:
|
21
|
+
RBench.run(TIMES) do
|
22
|
+
|
23
|
+
column :one
|
24
|
+
column :two
|
25
|
+
|
26
|
+
report "Squeezing with #squeeze" do
|
27
|
+
one { "abc//def//ghi//jkl".squeeze("/") }
|
28
|
+
two { "abc///def///ghi///jkl".squeeze("/") }
|
29
|
+
end
|
30
|
+
|
31
|
+
report "Squeezing with #gsub" do
|
32
|
+
one { "abc//def//ghi//jkl".gsub(/\/+/, "/") }
|
33
|
+
two { "abc///def///ghi///jkl".gsub(/\/+/, "/") }
|
34
|
+
end
|
35
|
+
|
36
|
+
report "Splitting with #split" do
|
37
|
+
one { "aaa/aaa/aaa.bbb.ccc.ddd".split(".") }
|
38
|
+
two { "aaa//aaa//aaa.bbb.ccc.ddd.eee".split(".") }
|
39
|
+
end
|
40
|
+
|
41
|
+
report "Splitting with #match" do
|
42
|
+
one { "aaa/aaa/aaa.bbb.ccc.ddd".match(/\.([^\.]*)$/) }
|
43
|
+
two { "aaa//aaa//aaa.bbb.ccc.ddd.eee".match(/\.([^\.]*)$/) }
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
# The benchmark above will output the following:
|
49
|
+
ONE | TWO |
|
50
|
+
--------------------------------------------------------------------------------
|
51
|
+
Squeezing with #squeeze 0.122 | 0.118 |
|
52
|
+
Squeezing with #gsub 0.274 | 0.271 |
|
53
|
+
Splitting with #split 0.349 | 0.394 |
|
54
|
+
Splitting with #match 0.238 | 0.291 |
|
55
|
+
|
56
|
+
|
57
|
+
# Now onto a benchmark that utilizes a some more stiff.
|
58
|
+
RBench.run(TIMES) do
|
59
|
+
|
60
|
+
format :width => 65
|
61
|
+
|
62
|
+
column :times
|
63
|
+
column :one, :title => "#1"
|
64
|
+
column :two, :title => "#2"
|
65
|
+
column :diff, :title => "#1/#2", :compare => [:one,:two]
|
66
|
+
|
67
|
+
group "Squeezing" do
|
68
|
+
report "with #squeeze" do
|
69
|
+
one { "abc//def//ghi//jkl".squeeze("/") }
|
70
|
+
two { "abc///def///ghi///jkl".squeeze("/") }
|
71
|
+
end
|
72
|
+
report "with #gsub" do
|
73
|
+
one { "abc//def//ghi//jkl".gsub(/\/+/, "/") }
|
74
|
+
two { "abc///def///ghi///jkl".gsub(/\/+/, "/") }
|
75
|
+
end
|
76
|
+
|
77
|
+
summary "all methods (totals)"
|
78
|
+
end
|
79
|
+
|
80
|
+
group "Splitting" do
|
81
|
+
report "with #split" do
|
82
|
+
one { "aaa/aaa/aaa.bbb.ccc.ddd".split(".") }
|
83
|
+
two { "aaa//aaa//aaa.bbb.ccc.ddd.eee".split(".") }
|
84
|
+
end
|
85
|
+
report "with #match", TIMES / 100 do
|
86
|
+
one { "aaa/aaa/aaa.bbb.ccc.ddd".match(/\.([^\.]*)$/) }
|
87
|
+
two { "aaa//aaa//aaa.bbb.ccc.ddd.eee".match(/\.([^\.]*)$/) }
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
# The benchmark above will output the following:
|
94
|
+
| #1 | #2 | #1/#2 |
|
95
|
+
--Squeezing------------------------------------------------------
|
96
|
+
with #squeeze x100000 | 0.122 | 0.117 | 1.04x |
|
97
|
+
with #gsub x100000 | 0.267 | 0.279 | 0.96x |
|
98
|
+
all methods (totals) | 0.390 | 0.396 | 0.98x |
|
99
|
+
--Splitting------------------------------------------------------
|
100
|
+
with #split x100000 | 0.341 | 0.394 | 0.87x |
|
101
|
+
with #match x1000 | 0.002 | 0.003 | 0.82x |
|
102
|
+
|
103
|
+
|
data/Rakefile
ADDED
data/TODO
ADDED
data/lib/rbench.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'benchmark'
|
3
|
+
|
4
|
+
dir = Pathname(__FILE__).dirname.expand_path + 'rbench'
|
5
|
+
|
6
|
+
require dir + 'runner'
|
7
|
+
require dir + 'column'
|
8
|
+
require dir + 'group'
|
9
|
+
require dir + 'report'
|
10
|
+
require dir + 'summary'
|
11
|
+
|
12
|
+
module RBench
|
13
|
+
def self.run(times, &block)
|
14
|
+
Runner.new(times).run(&block)
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: somebee-rbench
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "0.1"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yehuda Katz & Sindre Aarsaether
|
8
|
+
autorequire: rbench
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-06-13 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Library for generating nice ruby-benchmarks
|
17
|
+
email: post [a] rbench [d] org
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
24
|
+
- LICENSE
|
25
|
+
- TODO
|
26
|
+
files:
|
27
|
+
- LICENSE
|
28
|
+
- README
|
29
|
+
- Rakefile
|
30
|
+
- lib/rbench.rb
|
31
|
+
- TODO
|
32
|
+
has_rdoc: true
|
33
|
+
homepage: http://www.rbench.org
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: "0"
|
50
|
+
version:
|
51
|
+
requirements: []
|
52
|
+
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 1.0.1
|
55
|
+
signing_key:
|
56
|
+
specification_version: 2
|
57
|
+
summary: Library for generating nice ruby-benchmarks
|
58
|
+
test_files: []
|
59
|
+
|