viiite 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +70 -0
- data/Gemfile +2 -9
- data/Gemfile.lock +11 -32
- data/README.md +42 -123
- data/examples/bench_attr_vs_method-1.8.7.jpeg +0 -0
- data/examples/bench_attr_vs_method-1.9.3.jpeg +0 -0
- data/examples/bench_attr_vs_method.rb +18 -0
- data/examples/bench_iteration.rb +2 -4
- data/examples/bench_sort.rb +2 -7
- data/lib/viiite.rb +40 -18
- data/lib/viiite/bdb.rb +28 -0
- data/lib/viiite/bdb/cached.rb +63 -0
- data/lib/viiite/bdb/immediate.rb +46 -0
- data/lib/viiite/bdb/utils.rb +16 -0
- data/lib/viiite/benchmark.rb +35 -0
- data/lib/viiite/benchmark/runner.rb +50 -0
- data/lib/viiite/command.rb +33 -2
- data/lib/viiite/command/commons.rb +22 -0
- data/lib/viiite/command/help.rb +4 -5
- data/lib/viiite/command/plot.rb +44 -44
- data/lib/viiite/command/plot/to_gnuplot.rb +65 -0
- data/lib/viiite/command/{graph_style.rash → plot/to_gnuplot_graph.rash} +0 -0
- data/lib/viiite/command/{serie_style.rash → plot/to_gnuplot_serie.rash} +0 -0
- data/lib/viiite/command/plot/to_highcharts.rb +38 -0
- data/lib/viiite/command/plot/to_highcharts_graph.rb +29 -0
- data/lib/viiite/command/plot/to_text.rb +30 -0
- data/lib/viiite/command/report.rb +32 -10
- data/lib/viiite/command/run.rb +30 -7
- data/lib/viiite/errors.rb +5 -0
- data/lib/viiite/loader.rb +2 -2
- data/lib/viiite/tms.rb +21 -31
- data/lib/viiite/version.rb +5 -5
- data/spec/fixtures/bdb/Array/bench_sort.rb +7 -0
- data/spec/fixtures/{bench_iteration.rb → bdb/bench_iteration.rb} +2 -4
- data/spec/fixtures/command/bench_iteration.rb +3 -0
- data/spec/fixtures/saved/Array/bench_sort.rash +12 -0
- data/spec/fixtures/saved/bench_iteration.rash +18 -0
- data/spec/integration/plot/plot_1.cmd +1 -0
- data/spec/integration/plot/plot_1.stdout +64 -0
- data/spec/integration/plot/plot_2.cmd +1 -0
- data/spec/integration/plot/plot_2.stdout +37 -0
- data/spec/integration/plot/plot_3.cmd +1 -0
- data/spec/integration/plot/plot_3.stdout +64 -0
- data/spec/integration/plot/plot_4.cmd +1 -0
- data/spec/integration/plot/plot_4.stdout +1 -0
- data/spec/integration/report/viiite_report_1.cmd +1 -1
- data/spec/integration/report/viiite_report_1.stdout +7 -7
- data/spec/integration/report/viiite_report_2.cmd +1 -1
- data/spec/integration/report/viiite_report_2.stdout +22 -10
- data/spec/integration/report/viiite_report_3.cmd +1 -1
- data/spec/integration/report/viiite_report_3.stdout +46 -18
- data/spec/integration/report/viiite_report_4.cmd +1 -1
- data/spec/integration/report/viiite_report_4.stdout +34 -22
- data/spec/integration/report/viiite_report_5.cmd +1 -0
- data/spec/integration/report/viiite_report_5.stdout +7 -0
- data/spec/integration/report/viiite_report_6.cmd +1 -0
- data/spec/integration/report/viiite_report_6.stdout +7 -0
- data/spec/integration/report/viiite_report_7.cmd +1 -0
- data/spec/integration/report/viiite_report_7.stdout +7 -0
- data/spec/integration/report/viiite_report_8.cmd +1 -0
- data/spec/integration/report/viiite_report_8.stdout +16 -0
- data/spec/integration/report/viiite_report_9.cmd +1 -0
- data/spec/integration/report/viiite_report_9.stdout +88 -0
- data/spec/integration/test_command.rb +19 -23
- data/spec/integration/viiite/viiite_help.stdout +6 -0
- data/spec/spec_helper.rb +11 -17
- data/spec/unit/bdb/cached/test_dataset.rb +68 -0
- data/spec/unit/bdb/immediate/test_benchmark.rb +31 -0
- data/spec/unit/bdb/immediate/test_dataset.rb +31 -0
- data/spec/unit/bdb/immediate/test_enumerable.rb +20 -0
- data/spec/unit/bdb/immediate/test_pattern.rb +25 -0
- data/spec/unit/bdb/test_new.rb +44 -0
- data/spec/unit/bdb/utils/test_bench_file.rb +24 -0
- data/spec/unit/bdb/utils/test_replace_extension.rb +21 -0
- data/spec/unit/benchmark/bench_add.rb +3 -0
- data/spec/unit/benchmark/test_new.rb +28 -0
- data/spec/unit/command/commons/existing.rash +1 -0
- data/spec/unit/command/commons/test_single_source.rb +64 -0
- data/spec/unit/{formatter/plot → command/plot/gnuplot_utils}/test_to_data.rb +4 -4
- data/spec/unit/{formatter/plot → command/plot/gnuplot_utils}/test_to_dataset.rb +5 -5
- data/spec/unit/{formatter/plot → command/plot/gnuplot_utils}/test_to_plot.rb +4 -4
- data/spec/unit/command/test_run.rb +25 -12
- data/spec/unit/{test_runner.rb → test_benchmark.rb} +30 -11
- data/spec/unit/test_viiite.rb +17 -4
- data/spec/unit/tms/test_attributes.rb +11 -0
- data/spec/unit/tms/test_coerce.rb +11 -23
- data/spec/unit/tms/test_conversions.rb +23 -0
- data/spec/unit/tms/test_operations.rb +22 -0
- data/tasks/clean.rake +1 -1
- data/tasks/debug_mail.rake +13 -13
- data/tasks/gem.rake +13 -13
- data/tasks/integration_test.rake +3 -3
- data/tasks/spec_test.rake +9 -9
- data/tasks/unit_test.rake +9 -10
- data/tasks/yard.rake +13 -13
- data/viiite.gemspec +26 -29
- data/viiite.noespec +4 -7
- metadata +335 -235
- data/examples/bench_sort.eps +0 -816
- data/examples/bench_sort.rash +0 -100
- data/examples/raw.rash +0 -6
- data/lib/viiite/formatter.rb +0 -5
- data/lib/viiite/formatter/plot.rb +0 -38
- data/lib/viiite/runner.rb +0 -59
- data/lib/viiite/viiite_file.rb +0 -20
- data/spec/integration/raw_data.rash +0 -6
- data/spec/unit/tms/test_divide.rb +0 -26
- data/spec/unit/tms/test_minus.rb +0 -26
- data/spec/unit/tms/test_plus.rb +0 -34
- data/spec/unit/tms/test_times.rb +0 -26
- data/spec/unit/tms/test_to_a.rb +0 -11
- data/spec/unit/tms/test_to_ruby_literal.rb +0 -11
- data/spec/unit/tms/test_to_s.rb +0 -11
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,73 @@
|
|
1
|
+
# 0.2.0
|
2
|
+
|
3
|
+
## Awesome new features
|
4
|
+
|
5
|
+
* Viiite is now able to work on complete benchmark suites (located in
|
6
|
+
'./benchmarks' and looking for '**/*.rb' files by default). Subcommands
|
7
|
+
automatically resolve benchmark names passed as arguments. For example:
|
8
|
+
|
9
|
+
./benchmarks/
|
10
|
+
bench_iteration.rb -> viiite run bench_iteration
|
11
|
+
Array/
|
12
|
+
bench_sort.rb -> viiite run Array/bench_sort
|
13
|
+
|
14
|
+
* Default behavior remains compatible with 0.1.0:
|
15
|
+
* 'run', 'plot' and 'report' accept a benchmark file as first argument and
|
16
|
+
bypass the benchmark suite in this case.
|
17
|
+
* when invoked without any argument, 'plot' and 'report' assume a .rash stream
|
18
|
+
on standard input
|
19
|
+
|
20
|
+
* For each benchmark, the results of the last run are saved in a cache. 'plot'
|
21
|
+
and 'report' will use data in the cache if available or automatically run the
|
22
|
+
benchmark.
|
23
|
+
|
24
|
+
* The default behavior may be controlled through the following main options:
|
25
|
+
--suite=[FOLDER], --pattern=[GLOB], --[no-]cache=[FOLDER], --append, --write. Example:
|
26
|
+
|
27
|
+
# Run all benchmarks on all rubies, 10 times each, appending all results
|
28
|
+
# in cache
|
29
|
+
rvm exec viiite --append run --runs=10
|
30
|
+
|
31
|
+
## Enhancements to individual commands
|
32
|
+
|
33
|
+
* 'viiite run'
|
34
|
+
|
35
|
+
* Added a --runs=NB option to run the same benchmark NB times. This allows
|
36
|
+
keeping benchmarks clean; no NB.times{ ... } or range_over(1..NB, :run)
|
37
|
+
for obtaining a representative sample are needed in the benchmark itself.
|
38
|
+
* The previous option comes hand-in-hand with --run-key=KEY that allows
|
39
|
+
specifying the attribute name for the run number (defaults to :run)
|
40
|
+
* Without argument, runs all the benchmarks of the suite
|
41
|
+
|
42
|
+
* 'viiite plot'
|
43
|
+
|
44
|
+
* Added --highcharts options; outputs a json array containing one hash for
|
45
|
+
each chart, to be used as options Highcharts.Chart(...) (cfr. highcharts.js)
|
46
|
+
* Added -d option, to debug; outputs the query result that would be used by
|
47
|
+
the concrete --xxx formatter.
|
48
|
+
|
49
|
+
* 'viiite report'
|
50
|
+
|
51
|
+
* output has been improved: user, system, total and real time are explicitely
|
52
|
+
shown (different attributes/columns instead of one tms measure).
|
53
|
+
* added a '--ff=FORMAT' option for float format of the different measures
|
54
|
+
(defaults to %.6f)
|
55
|
+
* added a '--stddev=[MEASURE]' option for displaying standard deviation over
|
56
|
+
all regrouped runs (on a specific measure defaulting to tms.total)
|
57
|
+
|
58
|
+
## Other improvements
|
59
|
+
|
60
|
+
* The garbage collector is started before running report{ ... } blocks
|
61
|
+
* Viiite does not depend on benchmark (stdlib) anymore
|
62
|
+
* Improved Viiite.which_ruby; it should always output something like
|
63
|
+
'#{rubyname} #{version}#{patchlevel}' from now on
|
64
|
+
|
65
|
+
## Bug fixes
|
66
|
+
|
67
|
+
* Fixed a bug when using 'viiite report --regroup=x,y,z --hierarchy' with more
|
68
|
+
than 2 regrouping attributes.
|
69
|
+
|
70
|
+
|
1
71
|
# 0.1.0 / 2011-08-20
|
2
72
|
|
3
73
|
* Enhancements
|
data/Gemfile
CHANGED
@@ -11,15 +11,8 @@ group :release do
|
|
11
11
|
gem "wlang", "~> 0.10.2"
|
12
12
|
end
|
13
13
|
|
14
|
-
group :doc do
|
15
|
-
gem "yard", "~> 0.7.2"
|
16
|
-
gem "bluecloth", "~> 2.1.0"
|
17
|
-
gem "jekyll", "~> 0.11.0"
|
18
|
-
end
|
19
|
-
|
20
14
|
group :runtime do
|
21
|
-
gem "alf", "~> 0.10.
|
22
|
-
gem "quickl", "~> 0.4.0"
|
15
|
+
gem "alf", "~> 0.10.1"
|
23
16
|
gem "gnuplot", "~> 2.3.6"
|
17
|
+
gem "json", ">= 0"
|
24
18
|
end
|
25
|
-
|
data/Gemfile.lock
CHANGED
@@ -1,32 +1,16 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
bluecloth (2.1.0)
|
10
|
-
classifier (1.3.3)
|
11
|
-
fast-stemmer (>= 1.0.0)
|
12
|
-
diff-lcs (1.1.2)
|
13
|
-
directory_watcher (1.4.0)
|
14
|
-
fast-stemmer (1.0.0)
|
4
|
+
alf (0.10.1)
|
5
|
+
highline (~> 1.6.2)
|
6
|
+
myrrha (~> 1.2.1)
|
7
|
+
quickl (~> 0.4.1)
|
8
|
+
diff-lcs (1.1.3)
|
15
9
|
gnuplot (2.3.6)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
kramdown (>= 0.13.2)
|
21
|
-
liquid (>= 1.9.0)
|
22
|
-
maruku (>= 0.5.9)
|
23
|
-
kramdown (0.13.3)
|
24
|
-
liquid (2.2.2)
|
25
|
-
maruku (0.6.0)
|
26
|
-
syntax (>= 1.0.0)
|
27
|
-
myrrha (1.2.0)
|
28
|
-
posix-spawn (0.3.6)
|
29
|
-
quickl (0.4.0)
|
10
|
+
highline (1.6.2)
|
11
|
+
json (1.5.3)
|
12
|
+
myrrha (1.2.1)
|
13
|
+
quickl (0.4.1)
|
30
14
|
rake (0.9.2)
|
31
15
|
rspec (2.6.0)
|
32
16
|
rspec-core (~> 2.6.0)
|
@@ -36,20 +20,15 @@ GEM
|
|
36
20
|
rspec-expectations (2.6.0)
|
37
21
|
diff-lcs (~> 1.1.2)
|
38
22
|
rspec-mocks (2.6.0)
|
39
|
-
syntax (1.0.0)
|
40
23
|
wlang (0.10.2)
|
41
|
-
yard (0.7.2)
|
42
24
|
|
43
25
|
PLATFORMS
|
44
26
|
ruby
|
45
27
|
|
46
28
|
DEPENDENCIES
|
47
|
-
alf (~> 0.10.
|
48
|
-
bluecloth (~> 2.1.0)
|
29
|
+
alf (~> 0.10.1)
|
49
30
|
gnuplot (~> 2.3.6)
|
50
|
-
|
51
|
-
quickl (~> 0.4.0)
|
31
|
+
json
|
52
32
|
rake (~> 0.9.2)
|
53
33
|
rspec (~> 2.6.0)
|
54
34
|
wlang (~> 0.10.2)
|
55
|
-
yard (~> 0.7.2)
|
data/README.md
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
# Viiite
|
2
2
|
|
3
|
-
Viiite brings tools to benchmark and analyze the complexity of your algorithms.
|
4
|
-
It has been designed as an alternative to Benchmark that let your benchmarks
|
3
|
+
Viiite brings tools to benchmark and analyze the complexity of your algorithms.
|
4
|
+
It has been designed as an alternative to Benchmark that let your benchmarks
|
5
5
|
evolve smoothly from simple measures to more complex infrastructures.
|
6
6
|
|
7
7
|
[sudo] gem install viiite
|
8
8
|
|
9
9
|
Viiite uses [semantic versionning](http://semver.org) and has not yet reached the
|
10
|
-
public API required for 1.0.0. The safe way to require viiite for now is as
|
10
|
+
public API required for 1.0.0. The safe way to require viiite for now is as
|
11
11
|
follows:
|
12
12
|
|
13
|
-
gem "viiite", "~> 0.
|
13
|
+
gem "viiite", "~> 0.2.0"
|
14
14
|
|
15
15
|
Learn more on the [github-pages of this project](http://blambeau.github.com/viiite)!
|
16
16
|
|
@@ -22,9 +22,8 @@ Learn more on the [github-pages of this project](http://blambeau.github.com/viii
|
|
22
22
|
## From simple measures ...
|
23
23
|
|
24
24
|
```ruby
|
25
|
-
|
26
|
-
n = 15000
|
27
|
-
Viiite.bm do |r|
|
25
|
+
Viiite.bench do |r|
|
26
|
+
n = 15000
|
28
27
|
r.report(:for) { for i in 1..n; a = "1"; end }
|
29
28
|
r.report(:times) { n.times do ; a = "1"; end }
|
30
29
|
r.report(:upto) { 1.upto(n) do ; a = "1"; end }
|
@@ -33,22 +32,21 @@ end
|
|
33
32
|
|
34
33
|
```terminal
|
35
34
|
$ viiite report bench_iteration.rb
|
36
|
-
|
37
|
-
| :bench | :
|
38
|
-
|
39
|
-
| :for |
|
40
|
-
| :times |
|
41
|
-
| :upto |
|
42
|
-
|
35
|
+
+--------+----------+----------+----------+----------+
|
36
|
+
| :bench | :user | :system | :total | :real |
|
37
|
+
+--------+----------+----------+----------+----------+
|
38
|
+
| :for | 0.010000 | 0.000000 | 0.010000 | 0.013039 |
|
39
|
+
| :times | 0.000000 | 0.000000 | 0.000000 | 0.003753 |
|
40
|
+
| :upto | 0.010000 | 0.000000 | 0.010000 | 0.003803 |
|
41
|
+
+--------+----------+----------+----------+----------+
|
43
42
|
```
|
44
43
|
|
45
44
|
## To more complex ones ...
|
46
45
|
|
47
46
|
```ruby
|
48
|
-
|
49
|
-
n = 15000
|
50
|
-
Viiite.bm do |r|
|
47
|
+
Viiite.bench do |r|
|
51
48
|
r.variation_point :ruby, Viiite.which_ruby
|
49
|
+
n = 15000
|
52
50
|
r.report(:for) { for i in 1..n; a = "1"; end }
|
53
51
|
r.report(:times) { n.times do ; a = "1"; end }
|
54
52
|
r.report(:upto) { 1.upto(n) do ; a = "1"; end }
|
@@ -56,96 +54,43 @@ end
|
|
56
54
|
```
|
57
55
|
|
58
56
|
```terminal
|
59
|
-
$ rvm exec viiite run bench_iteration.rb | viiite report --hierarchy --regroup=
|
60
|
-
|
61
|
-
| :bench | :measure
|
62
|
-
|
63
|
-
| :for |
|
64
|
-
| | | :ruby | :
|
65
|
-
| |
|
66
|
-
| | | ruby 1.8.7 |
|
67
|
-
| | | ruby 1.9.3dev |
|
68
|
-
| |
|
69
|
-
|
|
70
|
-
| :
|
71
|
-
| |
|
72
|
-
| |
|
73
|
-
| | | ruby 1.
|
74
|
-
| |
|
75
|
-
|
|
76
|
-
| |
|
77
|
-
|
|
57
|
+
$ rvm exec viiite run bench_iteration.rb | viiite report --hierarchy --regroup=bench,ruby
|
58
|
+
+--------+-------------------------------------------------------+
|
59
|
+
| :bench | :measure |
|
60
|
+
+--------+-------------------------------------------------------+
|
61
|
+
| :for | +----------------+-------+---------+--------+-------+ |
|
62
|
+
| | | :ruby | :user | :system | :total | :real | |
|
63
|
+
| | +----------------+-------+---------+--------+-------+ |
|
64
|
+
| | | ruby 1.8.7 | 0.000 | 0.000 | 0.000 | 0.004 | |
|
65
|
+
| | | ruby 1.9.3dev | 0.010 | 0.000 | 0.010 | 0.014 | |
|
66
|
+
| | +----------------+-------+---------+--------+-------+ |
|
67
|
+
| :times | +----------------+-------+---------+--------+-------+ |
|
68
|
+
| | | :ruby | :user | :system | :total | :real | |
|
69
|
+
| | +----------------+-------+---------+--------+-------+ |
|
70
|
+
| | | ruby 1.8.7 | 0.020 | 0.000 | 0.020 | 0.018 | |
|
71
|
+
| | | ruby 1.9.3dev | 0.010 | 0.000 | 0.010 | 0.004 | |
|
72
|
+
| | +----------------+-------+---------+--------+-------+ |
|
73
|
+
| :upto | +----------------+-------+---------+--------+-------+ |
|
74
|
+
| | | :ruby | :user | :system | :total | :real | |
|
75
|
+
| | +----------------+-------+---------+--------+-------+ |
|
76
|
+
| | | ruby 1.8.7 | 0.010 | 0.000 | 0.010 | 0.004 | |
|
77
|
+
| | | ruby 1.9.3dev | 0.010 | 0.000 | 0.010 | 0.011 | |
|
78
|
+
| | +----------------+-------+---------+--------+-------+ |
|
79
|
+
+--------+-------------------------------------------------------+
|
78
80
|
```
|
79
81
|
|
80
82
|
## To awesomeness ...
|
81
83
|
|
82
84
|
```ruby
|
83
|
-
|
84
|
-
Viiite.bm do |b|
|
85
|
+
Viiite.bench do |b|
|
85
86
|
b.variation_point :ruby, Viiite.which_ruby
|
86
87
|
b.range_over([100, 200, 300, 400, 500], :size) do |size|
|
87
|
-
|
88
|
-
|
89
|
-
b.report(:quicksort) { bench_case.quicksort }
|
90
|
-
b.report(:bubblesort){ bench_case.bubblesort }
|
91
|
-
end
|
88
|
+
bench_case = Array.new(size){ rand }
|
89
|
+
b.report(:bubblesort){ bench_case.bubblesort }
|
92
90
|
end
|
93
91
|
end
|
94
92
|
```
|
95
93
|
|
96
|
-
```terminal
|
97
|
-
$ viiite plot bench_sort.rb -x size -y tms.total --graph=ruby --series=viiite --gnuplot | gnuplot
|
98
|
-
|
99
|
-
ruby 1.8.7
|
100
|
-
|
101
|
-
0.35 ++-------+-------+--------+-------+--------+--------+-------+-------++
|
102
|
-
+ + + + + + bubblesort **A*** +
|
103
|
-
| quicksort ##B###*A
|
104
|
-
0.3 ++ ***++
|
105
|
-
| *** |
|
106
|
-
0.25 ++ ** ++
|
107
|
-
| *** |
|
108
|
-
| *** |
|
109
|
-
0.2 ++ *A* ++
|
110
|
-
| **** |
|
111
|
-
| **** |
|
112
|
-
0.15 ++ *** ++
|
113
|
-
| **** |
|
114
|
-
| **A* |
|
115
|
-
0.1 ++ ****** ++
|
116
|
-
| ****** |
|
117
|
-
0.05 ++ ****A** ++
|
118
|
-
| ******** |
|
119
|
-
A**** + + + + + + +########B
|
120
|
-
0 B################B################B#################B########-------++
|
121
|
-
100 150 200 250 300 350 400 450 500
|
122
|
-
|
123
|
-
|
124
|
-
ruby 1.9.3dev
|
125
|
-
|
126
|
-
0.1 ++-------+-------+--------+-------+--------+--------+-------+-------*A
|
127
|
-
+ + + + + + bubblesort **A*** +
|
128
|
-
| quicksort **B### |
|
129
|
-
| ** |
|
130
|
-
0.08 ++ *** ++
|
131
|
-
| *** |
|
132
|
-
| *A* |
|
133
|
-
| *** |
|
134
|
-
0.06 ++ *** ++
|
135
|
-
| *** |
|
136
|
-
| *** |
|
137
|
-
0.04 ++ *** ++
|
138
|
-
| **A* |
|
139
|
-
| **** |
|
140
|
-
| **** |
|
141
|
-
0.02 ++ **** ++
|
142
|
-
| **A** |
|
143
|
-
| ****** |
|
144
|
-
+ ******+ + + + + + +########B
|
145
|
-
0 A**##############B################B#################B########-------++
|
146
|
-
100 150 200 250 300 350 400 450 500
|
147
|
-
```
|
148
|
-
|
149
94
|
```terminal
|
150
95
|
$ viiite plot bench_sort.rb -x size -y tms.total --graph=viiite --series=ruby --gnuplot | gnuplot
|
151
96
|
bubblesort
|
@@ -171,34 +116,8 @@ $ viiite plot bench_sort.rb -x size -y tms.total --graph=viiite --series=ruby --
|
|
171
116
|
A**** ########B########+ + + + + +
|
172
117
|
0 B########+-------+--------+-------+--------+--------+-------+-------++
|
173
118
|
100 150 200 250 300 350 400 450 500
|
174
|
-
|
175
|
-
|
176
|
-
quicksort
|
177
|
-
|
178
|
-
0.012 ++-------+-------+--------+-------+--------+-------+--------+------++
|
179
|
-
+ + + + + + ruby 1.8.7+**A*** +
|
180
|
-
| ruby 1.9.3dev ##B### |
|
181
|
-
0.01 ++ **A
|
182
|
-
| ****** |
|
183
|
-
| ****** |
|
184
|
-
0.008 ++ A** ++
|
185
|
-
| ** |
|
186
|
-
| ** |
|
187
|
-
| * B
|
188
|
-
0.006 ++ ** ##+
|
189
|
-
| ** ## |
|
190
|
-
| ** # |
|
191
|
-
0.004 ++ * ## ++
|
192
|
-
| ** ## |
|
193
|
-
| ** ## |
|
194
|
-
0.002 ++ ##B##############**A######## # ++
|
195
|
-
| ###### ****** ###### ## |
|
196
|
-
+ ######+ + ******+ + + ##+## + +
|
197
|
-
0 A****************A**------+-------+--------+-------B--------+------++
|
198
|
-
100 150 200 250 300 350 400 450 500
|
199
|
-
|
200
119
|
```
|
201
120
|
|
202
121
|
## On the devel side
|
203
122
|
|
204
|
-
Fork the project on github ... and so on.
|
123
|
+
Fork the project on github ... and so on.
|
Binary file
|
Binary file
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Foo
|
2
|
+
attr_reader :bench_reader
|
3
|
+
def initialize
|
4
|
+
@bench_reader = @bench_method = 10
|
5
|
+
end
|
6
|
+
def bench_method
|
7
|
+
@bench_method
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
Viiite.bench do |b|
|
12
|
+
foo = Foo.new
|
13
|
+
b.variation_point :ruby, Viiite.which_ruby
|
14
|
+
b.range_over([1, 100_000, 1_000_000], :runs) do |runs|
|
15
|
+
b.report(:bench_reader){ runs.times{ foo.bench_reader } }
|
16
|
+
b.report(:bench_method){ runs.times{ foo.bench_method } }
|
17
|
+
end
|
18
|
+
end
|
data/examples/bench_iteration.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
|
-
|
2
|
-
n = 15000
|
3
|
-
Viiite.bm do |r|
|
1
|
+
Viiite.bench do |r|
|
2
|
+
n = 15000
|
4
3
|
r.variation_point :ruby, Viiite.which_ruby
|
5
4
|
r.report(:for) { for i in 1..n; a = "1"; end }
|
6
5
|
r.report(:times) { n.times do ; a = "1"; end }
|
7
6
|
r.report(:upto) { 1.upto(n) do ; a = "1"; end }
|
8
7
|
end
|
9
|
-
|
data/examples/bench_sort.rb
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
class Array
|
2
2
|
|
3
|
-
def self.random(size)
|
4
|
-
Array.new(size){ Kernel.rand }
|
5
|
-
end
|
6
|
-
|
7
3
|
def quicksort(list = self)
|
8
4
|
return list if list.nil? or list.size <= 1
|
9
5
|
less, more = list[1..-1].partition { |i| i < list[0] }
|
@@ -25,14 +21,13 @@ class Array
|
|
25
21
|
end
|
26
22
|
|
27
23
|
require 'viiite'
|
28
|
-
Viiite.
|
24
|
+
Viiite.bench do |b|
|
29
25
|
b.variation_point :ruby, Viiite.which_ruby
|
30
26
|
b.range_over([100, 200, 300, 400, 500], :size) do |size|
|
31
27
|
b.range_over(1..5, :i) do
|
32
|
-
bench_case = Array.
|
28
|
+
bench_case = Array.new(size) { rand }
|
33
29
|
b.report(:quicksort) { bench_case.quicksort }
|
34
30
|
b.report(:bubblesort){ bench_case.bubblesort }
|
35
31
|
end
|
36
32
|
end
|
37
33
|
end
|
38
|
-
|
data/lib/viiite.rb
CHANGED
@@ -1,31 +1,35 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require "delegate"
|
3
|
+
|
1
4
|
require "viiite/version"
|
2
5
|
require "viiite/loader"
|
6
|
+
require "viiite/errors"
|
3
7
|
require "viiite/tms"
|
4
|
-
require "viiite/
|
5
|
-
require "viiite/runner"
|
8
|
+
require "viiite/benchmark"
|
6
9
|
require "viiite/command"
|
7
|
-
require "viiite/
|
8
|
-
require "benchmark"
|
10
|
+
require "viiite/bdb"
|
9
11
|
|
10
12
|
#
|
11
13
|
# Benchmarking and complexity analyzer utility
|
12
14
|
#
|
13
15
|
module Viiite
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
def self.measure
|
18
|
+
t0, r0 = Process.times, Time.now
|
19
|
+
yield
|
20
|
+
t1, r1 = Process.times, Time.now
|
21
|
+
Tms.new(t1.utime - t0.utime,
|
22
|
+
t1.stime - t0.stime,
|
23
|
+
t1.cutime - t0.cutime,
|
24
|
+
t1.cstime - t0.cstime,
|
25
|
+
r1 - r0)
|
22
26
|
end
|
23
27
|
|
24
28
|
# Builds a runner instance via the DSL definition given by the block.
|
25
29
|
#
|
26
30
|
# Example
|
27
31
|
#
|
28
|
-
# Viiite.
|
32
|
+
# Viiite.bench do |b|
|
29
33
|
# b.variation_point :ruby_version, Viiite.which_ruby
|
30
34
|
# b.range_over([100, 1000, 10000, 100000], :runs) do |runs|
|
31
35
|
# b.variation_point :test, :via_reader do
|
@@ -36,20 +40,38 @@ module Viiite
|
|
36
40
|
# end
|
37
41
|
# end
|
38
42
|
# end
|
39
|
-
#
|
43
|
+
#
|
44
|
+
def self.bench(&block)
|
45
|
+
Benchmark.new(block)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Alias of Viiite.bench for compatibility
|
40
49
|
def self.bm(&block)
|
41
|
-
|
50
|
+
warn "Viiite.bm is deprecated, use Viiite.bench instead #{caller[0]}"
|
51
|
+
bench(&block)
|
42
52
|
end
|
43
53
|
|
44
54
|
#
|
45
55
|
# Returns a short string with a ruby interpreter description
|
46
|
-
#
|
56
|
+
#
|
47
57
|
def self.which_ruby
|
48
58
|
if Object.const_defined?(:RUBY_DESCRIPTION)
|
49
|
-
RUBY_DESCRIPTION
|
50
|
-
|
59
|
+
short_ruby_description(RUBY_DESCRIPTION)
|
60
|
+
else
|
61
|
+
"ruby #{RUBY_VERSION}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.short_ruby_description(description)
|
66
|
+
case description
|
67
|
+
when /Ruby Enterprise Edition (\d{4}\.\d{2})/
|
68
|
+
"ree #{$1}"
|
69
|
+
when /^(\w+ \d\.\d\.\d) .+ patchlevel (\d+)/
|
70
|
+
"#{$1}p#{$2}"
|
71
|
+
when /^\w+ \S+/
|
72
|
+
$&
|
51
73
|
else
|
52
|
-
"ruby
|
74
|
+
raise "Unknown ruby interpreter: #{description}"
|
53
75
|
end
|
54
76
|
end
|
55
77
|
|