viiite 0.1.0 → 0.2.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.
Files changed (113) hide show
  1. data/CHANGELOG.md +70 -0
  2. data/Gemfile +2 -9
  3. data/Gemfile.lock +11 -32
  4. data/README.md +42 -123
  5. data/examples/bench_attr_vs_method-1.8.7.jpeg +0 -0
  6. data/examples/bench_attr_vs_method-1.9.3.jpeg +0 -0
  7. data/examples/bench_attr_vs_method.rb +18 -0
  8. data/examples/bench_iteration.rb +2 -4
  9. data/examples/bench_sort.rb +2 -7
  10. data/lib/viiite.rb +40 -18
  11. data/lib/viiite/bdb.rb +28 -0
  12. data/lib/viiite/bdb/cached.rb +63 -0
  13. data/lib/viiite/bdb/immediate.rb +46 -0
  14. data/lib/viiite/bdb/utils.rb +16 -0
  15. data/lib/viiite/benchmark.rb +35 -0
  16. data/lib/viiite/benchmark/runner.rb +50 -0
  17. data/lib/viiite/command.rb +33 -2
  18. data/lib/viiite/command/commons.rb +22 -0
  19. data/lib/viiite/command/help.rb +4 -5
  20. data/lib/viiite/command/plot.rb +44 -44
  21. data/lib/viiite/command/plot/to_gnuplot.rb +65 -0
  22. data/lib/viiite/command/{graph_style.rash → plot/to_gnuplot_graph.rash} +0 -0
  23. data/lib/viiite/command/{serie_style.rash → plot/to_gnuplot_serie.rash} +0 -0
  24. data/lib/viiite/command/plot/to_highcharts.rb +38 -0
  25. data/lib/viiite/command/plot/to_highcharts_graph.rb +29 -0
  26. data/lib/viiite/command/plot/to_text.rb +30 -0
  27. data/lib/viiite/command/report.rb +32 -10
  28. data/lib/viiite/command/run.rb +30 -7
  29. data/lib/viiite/errors.rb +5 -0
  30. data/lib/viiite/loader.rb +2 -2
  31. data/lib/viiite/tms.rb +21 -31
  32. data/lib/viiite/version.rb +5 -5
  33. data/spec/fixtures/bdb/Array/bench_sort.rb +7 -0
  34. data/spec/fixtures/{bench_iteration.rb → bdb/bench_iteration.rb} +2 -4
  35. data/spec/fixtures/command/bench_iteration.rb +3 -0
  36. data/spec/fixtures/saved/Array/bench_sort.rash +12 -0
  37. data/spec/fixtures/saved/bench_iteration.rash +18 -0
  38. data/spec/integration/plot/plot_1.cmd +1 -0
  39. data/spec/integration/plot/plot_1.stdout +64 -0
  40. data/spec/integration/plot/plot_2.cmd +1 -0
  41. data/spec/integration/plot/plot_2.stdout +37 -0
  42. data/spec/integration/plot/plot_3.cmd +1 -0
  43. data/spec/integration/plot/plot_3.stdout +64 -0
  44. data/spec/integration/plot/plot_4.cmd +1 -0
  45. data/spec/integration/plot/plot_4.stdout +1 -0
  46. data/spec/integration/report/viiite_report_1.cmd +1 -1
  47. data/spec/integration/report/viiite_report_1.stdout +7 -7
  48. data/spec/integration/report/viiite_report_2.cmd +1 -1
  49. data/spec/integration/report/viiite_report_2.stdout +22 -10
  50. data/spec/integration/report/viiite_report_3.cmd +1 -1
  51. data/spec/integration/report/viiite_report_3.stdout +46 -18
  52. data/spec/integration/report/viiite_report_4.cmd +1 -1
  53. data/spec/integration/report/viiite_report_4.stdout +34 -22
  54. data/spec/integration/report/viiite_report_5.cmd +1 -0
  55. data/spec/integration/report/viiite_report_5.stdout +7 -0
  56. data/spec/integration/report/viiite_report_6.cmd +1 -0
  57. data/spec/integration/report/viiite_report_6.stdout +7 -0
  58. data/spec/integration/report/viiite_report_7.cmd +1 -0
  59. data/spec/integration/report/viiite_report_7.stdout +7 -0
  60. data/spec/integration/report/viiite_report_8.cmd +1 -0
  61. data/spec/integration/report/viiite_report_8.stdout +16 -0
  62. data/spec/integration/report/viiite_report_9.cmd +1 -0
  63. data/spec/integration/report/viiite_report_9.stdout +88 -0
  64. data/spec/integration/test_command.rb +19 -23
  65. data/spec/integration/viiite/viiite_help.stdout +6 -0
  66. data/spec/spec_helper.rb +11 -17
  67. data/spec/unit/bdb/cached/test_dataset.rb +68 -0
  68. data/spec/unit/bdb/immediate/test_benchmark.rb +31 -0
  69. data/spec/unit/bdb/immediate/test_dataset.rb +31 -0
  70. data/spec/unit/bdb/immediate/test_enumerable.rb +20 -0
  71. data/spec/unit/bdb/immediate/test_pattern.rb +25 -0
  72. data/spec/unit/bdb/test_new.rb +44 -0
  73. data/spec/unit/bdb/utils/test_bench_file.rb +24 -0
  74. data/spec/unit/bdb/utils/test_replace_extension.rb +21 -0
  75. data/spec/unit/benchmark/bench_add.rb +3 -0
  76. data/spec/unit/benchmark/test_new.rb +28 -0
  77. data/spec/unit/command/commons/existing.rash +1 -0
  78. data/spec/unit/command/commons/test_single_source.rb +64 -0
  79. data/spec/unit/{formatter/plot → command/plot/gnuplot_utils}/test_to_data.rb +4 -4
  80. data/spec/unit/{formatter/plot → command/plot/gnuplot_utils}/test_to_dataset.rb +5 -5
  81. data/spec/unit/{formatter/plot → command/plot/gnuplot_utils}/test_to_plot.rb +4 -4
  82. data/spec/unit/command/test_run.rb +25 -12
  83. data/spec/unit/{test_runner.rb → test_benchmark.rb} +30 -11
  84. data/spec/unit/test_viiite.rb +17 -4
  85. data/spec/unit/tms/test_attributes.rb +11 -0
  86. data/spec/unit/tms/test_coerce.rb +11 -23
  87. data/spec/unit/tms/test_conversions.rb +23 -0
  88. data/spec/unit/tms/test_operations.rb +22 -0
  89. data/tasks/clean.rake +1 -1
  90. data/tasks/debug_mail.rake +13 -13
  91. data/tasks/gem.rake +13 -13
  92. data/tasks/integration_test.rake +3 -3
  93. data/tasks/spec_test.rake +9 -9
  94. data/tasks/unit_test.rake +9 -10
  95. data/tasks/yard.rake +13 -13
  96. data/viiite.gemspec +26 -29
  97. data/viiite.noespec +4 -7
  98. metadata +335 -235
  99. data/examples/bench_sort.eps +0 -816
  100. data/examples/bench_sort.rash +0 -100
  101. data/examples/raw.rash +0 -6
  102. data/lib/viiite/formatter.rb +0 -5
  103. data/lib/viiite/formatter/plot.rb +0 -38
  104. data/lib/viiite/runner.rb +0 -59
  105. data/lib/viiite/viiite_file.rb +0 -20
  106. data/spec/integration/raw_data.rash +0 -6
  107. data/spec/unit/tms/test_divide.rb +0 -26
  108. data/spec/unit/tms/test_minus.rb +0 -26
  109. data/spec/unit/tms/test_plus.rb +0 -34
  110. data/spec/unit/tms/test_times.rb +0 -26
  111. data/spec/unit/tms/test_to_a.rb +0 -11
  112. data/spec/unit/tms/test_to_ruby_literal.rb +0 -11
  113. data/spec/unit/tms/test_to_s.rb +0 -11
@@ -0,0 +1 @@
1
+ viiite report --regroup=ruby,size,bench --hierarchy Array/bench_sort
@@ -0,0 +1,88 @@
1
+ +-------------------+---------------------------------------------------------------------------+
2
+ | :ruby | :measure |
3
+ +-------------------+---------------------------------------------------------------------------+
4
+ | jruby 1.6.3 | +-------+---------------------------------------------------------------+ |
5
+ | | | :size | :measure | |
6
+ | | +-------+---------------------------------------------------------------+ |
7
+ | | | 100 | +---------------+----------+----------+----------+----------+ | |
8
+ | | | | | :bench | :user | :system | :total | :real | | |
9
+ | | | | +---------------+----------+----------+----------+----------+ | |
10
+ | | | | | :"Array#sort" | 0.002000 | 0.000000 | 0.002000 | 0.002000 | | |
11
+ | | | | +---------------+----------+----------+----------+----------+ | |
12
+ | | | 1000 | +---------------+----------+----------+----------+----------+ | |
13
+ | | | | | :bench | :user | :system | :total | :real | | |
14
+ | | | | +---------------+----------+----------+----------+----------+ | |
15
+ | | | | | :"Array#sort" | 0.019000 | 0.000000 | 0.019000 | 0.020000 | | |
16
+ | | | | +---------------+----------+----------+----------+----------+ | |
17
+ | | +-------+---------------------------------------------------------------+ |
18
+ | rubinius 1.2.5dev | +-------+---------------------------------------------------------------+ |
19
+ | | | :size | :measure | |
20
+ | | +-------+---------------------------------------------------------------+ |
21
+ | | | 100 | +---------------+----------+----------+----------+----------+ | |
22
+ | | | | | :bench | :user | :system | :total | :real | | |
23
+ | | | | +---------------+----------+----------+----------+----------+ | |
24
+ | | | | | :"Array#sort" | 0.000000 | 0.000000 | 0.000000 | 0.000399 | | |
25
+ | | | | +---------------+----------+----------+----------+----------+ | |
26
+ | | | 1000 | +---------------+----------+----------+----------+----------+ | |
27
+ | | | | | :bench | :user | :system | :total | :real | | |
28
+ | | | | +---------------+----------+----------+----------+----------+ | |
29
+ | | | | | :"Array#sort" | 0.028002 | 0.000000 | 0.028002 | 0.042525 | | |
30
+ | | | | +---------------+----------+----------+----------+----------+ | |
31
+ | | +-------+---------------------------------------------------------------+ |
32
+ | rubinius 2.0.0dev | +-------+---------------------------------------------------------------+ |
33
+ | | | :size | :measure | |
34
+ | | +-------+---------------------------------------------------------------+ |
35
+ | | | 100 | +---------------+----------+----------+----------+----------+ | |
36
+ | | | | | :bench | :user | :system | :total | :real | | |
37
+ | | | | +---------------+----------+----------+----------+----------+ | |
38
+ | | | | | :"Array#sort" | 0.000000 | 0.000000 | 0.000000 | 0.000385 | | |
39
+ | | | | +---------------+----------+----------+----------+----------+ | |
40
+ | | | 1000 | +---------------+----------+----------+----------+----------+ | |
41
+ | | | | | :bench | :user | :system | :total | :real | | |
42
+ | | | | +---------------+----------+----------+----------+----------+ | |
43
+ | | | | | :"Array#sort" | 0.004000 | 0.000000 | 0.004000 | 0.005118 | | |
44
+ | | | | +---------------+----------+----------+----------+----------+ | |
45
+ | | +-------+---------------------------------------------------------------+ |
46
+ | ruby 1.8.7 | +-------+---------------------------------------------------------------+ |
47
+ | | | :size | :measure | |
48
+ | | +-------+---------------------------------------------------------------+ |
49
+ | | | 100 | +---------------+----------+----------+----------+----------+ | |
50
+ | | | | | :bench | :user | :system | :total | :real | | |
51
+ | | | | +---------------+----------+----------+----------+----------+ | |
52
+ | | | | | :"Array#sort" | 0.000000 | 0.000000 | 0.000000 | 0.000082 | | |
53
+ | | | | +---------------+----------+----------+----------+----------+ | |
54
+ | | | 1000 | +---------------+----------+----------+----------+----------+ | |
55
+ | | | | | :bench | :user | :system | :total | :real | | |
56
+ | | | | +---------------+----------+----------+----------+----------+ | |
57
+ | | | | | :"Array#sort" | 0.000000 | 0.000000 | 0.000000 | 0.001091 | | |
58
+ | | | | +---------------+----------+----------+----------+----------+ | |
59
+ | | +-------+---------------------------------------------------------------+ |
60
+ | ruby 1.9.2p290 | +-------+---------------------------------------------------------------+ |
61
+ | | | :size | :measure | |
62
+ | | +-------+---------------------------------------------------------------+ |
63
+ | | | 100 | +---------------+----------+----------+----------+----------+ | |
64
+ | | | | | :bench | :user | :system | :total | :real | | |
65
+ | | | | +---------------+----------+----------+----------+----------+ | |
66
+ | | | | | :"Array#sort" | 0.000000 | 0.000000 | 0.000000 | 0.000080 | | |
67
+ | | | | +---------------+----------+----------+----------+----------+ | |
68
+ | | | 1000 | +---------------+----------+----------+----------+----------+ | |
69
+ | | | | | :bench | :user | :system | :total | :real | | |
70
+ | | | | +---------------+----------+----------+----------+----------+ | |
71
+ | | | | | :"Array#sort" | 0.000000 | 0.000000 | 0.000000 | 0.001121 | | |
72
+ | | | | +---------------+----------+----------+----------+----------+ | |
73
+ | | +-------+---------------------------------------------------------------+ |
74
+ | ruby 1.9.3dev | +-------+---------------------------------------------------------------+ |
75
+ | | | :size | :measure | |
76
+ | | +-------+---------------------------------------------------------------+ |
77
+ | | | 100 | +---------------+----------+----------+----------+----------+ | |
78
+ | | | | | :bench | :user | :system | :total | :real | | |
79
+ | | | | +---------------+----------+----------+----------+----------+ | |
80
+ | | | | | :"Array#sort" | 0.000000 | 0.000000 | 0.000000 | 0.000084 | | |
81
+ | | | | +---------------+----------+----------+----------+----------+ | |
82
+ | | | 1000 | +---------------+----------+----------+----------+----------+ | |
83
+ | | | | | :bench | :user | :system | :total | :real | | |
84
+ | | | | +---------------+----------+----------+----------+----------+ | |
85
+ | | | | | :"Array#sort" | 0.000000 | 0.000000 | 0.000000 | 0.001163 | | |
86
+ | | | | +---------------+----------+----------+----------+----------+ | |
87
+ | | +-------+---------------------------------------------------------------+ |
88
+ +-------------------+---------------------------------------------------------------------------+
@@ -1,33 +1,29 @@
1
1
  require 'spec_helper'
2
- describe "viiite command / " do
2
+ describe "viiite commands" do
3
3
 
4
4
  Dir[File.expand_path('../**/*.cmd', __FILE__)].each do |input|
5
- cmd = File.readlines(input).first
6
- specify{ cmd.should =~ /^viiite / }
7
-
8
- describe "#{File.basename(input)}: #{cmd}" do
9
- let(:argv) { Quickl.parse_commandline_args(cmd)[1..-1] }
10
- let(:stdout) { File.join(File.dirname(input), "#{File.basename(input, ".cmd")}.stdout") }
11
- let(:stderr) { File.join(File.dirname(input), "#{File.basename(input, ".cmd")}.stderr") }
12
- let(:stdout_expected) { File.exists?(stdout) ? File.read(stdout) : "" }
13
- let(:stderr_expected) { File.exists?(stderr) ? File.read(stderr) : "" }
5
+ cmd = File.read(input).chomp
14
6
 
15
- before{ redirect_io }
16
- after { restore_io }
17
-
18
- specify{
7
+ specify "#{File.basename(input)}: #{cmd}" do
8
+ argv = Quickl.parse_commandline_args(cmd)[1..-1]
9
+ stdout = File.join(File.dirname(input), "#{File.basename(input, ".cmd")}.stdout")
10
+ stderr = File.join(File.dirname(input), "#{File.basename(input, ".cmd")}.stderr")
11
+ stdout_expected = File.exists?(stdout) ? File.read(stdout) : ""
12
+ stderr_expected = File.exists?(stderr) ? File.read(stderr) : ""
13
+
14
+ cmd.should match /^viiite /
15
+ cache = File.join(fixtures_folder, "saved")
16
+ out, err = capture_io do
19
17
  begin
20
- if i = argv.index("raw_data")
21
- argv[i] = File.expand_path('../raw_data.rash', __FILE__)
22
- end
23
- Viiite::Command.run(argv)
18
+ Viiite::Command.run(["--suite=#{fixtures_folder}/bdb", "--cache=#{cache}"] + argv)
24
19
  rescue SystemExit
25
- $stdout << "SystemExit" << "\n"
20
+ puts "SystemExit"
26
21
  end
27
- $stdout.string.should(eq(stdout_expected)) unless RUBY_VERSION < "1.9"
28
- $stderr.string.should(eq(stderr_expected)) unless RUBY_VERSION < "1.9"
29
- }
22
+ end
23
+
24
+ out.should eq stdout_expected unless RUBY_VERSION < "1.9"
25
+ err.should eq stderr_expected unless RUBY_VERSION < "1.9"
30
26
  end
31
27
  end
32
-
28
+
33
29
  end
@@ -7,6 +7,12 @@ SYNOPSIS
7
7
  OPTIONS
8
8
  -Idirectory specify $LOAD_PATH directory (may be used more than once)
9
9
  -rlibrary require the library, before executing viiite
10
+ --suite=FOLDER Specify the folder of the benchmark suite (defaults to 'benchmarks')
11
+ --pattern=GLOB Specify the pattern to find benchmarks in the suite folder (defaults to '**/*.rb')
12
+ --[no-]cache=[FOLDER] Specify the cache heuristic and folder (defaults to --cache)
13
+ --cache-mode=MODE Specify the exact mode for accessing cache files
14
+ -a, --append Shortcut to --cache-mode=a
15
+ -w, --write Shortcut to --cache-mode=w
10
16
  --help Show help
11
17
  --version Show version
12
18
 
@@ -1,23 +1,17 @@
1
1
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
2
  require 'viiite'
3
+ require 'stringio'
3
4
 
4
- def redirect_io
5
- $oldstdout = $stdout
6
- $oldstderr = $stderr
7
- $stdout = StringIO.new
8
- $stderr = StringIO.new
9
- [$stdout, $stderr]
5
+ def capture_io
6
+ stdout, stderr = $stdout, $stderr
7
+ out, err = StringIO.new, StringIO.new
8
+ $stdout, $stderr = out, err
9
+ yield
10
+ [out.string, err.string]
11
+ ensure
12
+ $stdout, $stderr = stdout, stderr
10
13
  end
11
14
 
12
- def restore_io
13
- $stdout = $oldstdout
14
- $stderr = $oldstderr
15
- $oldstdout = nil
16
- $oldstderr = nil
15
+ def fixtures_folder
16
+ File.expand_path('../fixtures', __FILE__)
17
17
  end
18
-
19
- def bench_iteration
20
- File.expand_path('../fixtures/bench_iteration.rb', __FILE__)
21
- end
22
-
23
-
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+
3
+ module Viiite
4
+ class BDB
5
+ describe Cached, "#dataset" do
6
+
7
+ let(:folder) { File.join(fixtures_folder, '.cache') }
8
+ let(:bdb) { Cached.new(delegate, folder) }
9
+ subject { bdb.dataset(name) }
10
+ before(:each){ FileUtils.rm_rf(folder) }
11
+
12
+ describe "when the benchmark exists" do
13
+ let(:delegate){
14
+ @delegate ||= Object.new.extend Module.new{
15
+ attr_reader :called
16
+ def benchmark(name)
17
+ @called = true
18
+ Alf::Relation[{:name => name}]
19
+ end
20
+ alias :dataset :benchmark
21
+ }
22
+ }
23
+ let(:name) { "Array/bench_sort" }
24
+ let(:cached){ File.join(folder, "Array", "bench_sort.rash") }
25
+ after{
26
+ File.exists?(cached).should be_true
27
+ FileUtils.rm_rf(cached)
28
+ }
29
+
30
+ describe 'when the cache file does not exist yet' do
31
+ before{
32
+ File.exists?(cached).should be_false
33
+ }
34
+ specify{
35
+ subject.to_a.should eq([{:name => 'Array/bench_sort'}])
36
+ delegate.called.should be_true
37
+ }
38
+ end
39
+
40
+ describe 'when the cache file already exists' do
41
+ before{
42
+ FileUtils.mkdir_p(File.dirname(cached))
43
+ File.open(cached, "w") do |io|
44
+ io << "{:name => 'Array/bench_sort'}"
45
+ end
46
+ }
47
+ specify{
48
+ subject.to_a.should eq([{:name => 'Array/bench_sort'}])
49
+ delegate.called.should be_false
50
+ }
51
+ end
52
+
53
+ end
54
+
55
+ describe "when the benchmark does not exist" do
56
+ let(:delegate){
57
+ Object.new.extend Module.new{
58
+ def benchmark(name); raise Alf::NoSuchDatasetError; end
59
+ alias :dataset :benchmark
60
+ }
61
+ }
62
+ let(:name){ "NotA/Class/bench_non_existing" }
63
+ specify{ lambda{subject}.should raise_error(Alf::NoSuchDatasetError) }
64
+ end
65
+
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+ module Viiite
3
+ class BDB
4
+ describe Immediate, "#benchmark" do
5
+
6
+ let(:bdb){ Immediate.new(fixtures_folder+'/bdb') }
7
+ subject{ bdb.benchmark(name) }
8
+
9
+ describe "when the file exists in root folder (String)" do
10
+ let(:name){ "bench_iteration" }
11
+ it{ should be_a(Viiite::Benchmark) }
12
+ end
13
+
14
+ describe "when the file exists in root folder (Symbol)" do
15
+ let(:name){ :bench_iteration }
16
+ it{ should be_a(Viiite::Benchmark) }
17
+ end
18
+
19
+ describe "when the file exists in a sub folder (String)" do
20
+ let(:name){ "Array/bench_sort" }
21
+ it{ should be_a(Viiite::Benchmark) }
22
+ end
23
+
24
+ describe "when the file does not exist" do
25
+ let(:name){ "NotA/Class/bench_non_existing" }
26
+ specify{ lambda{subject}.should raise_error(NoSuchBenchmarkError) }
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+ module Viiite
3
+ class BDB
4
+ describe Immediate, "#dataset" do
5
+
6
+ let(:bdb){ Immediate.new(fixtures_folder+'/bdb') }
7
+ subject{ bdb.dataset(name) }
8
+
9
+ describe "when the file exists in root folder (String)" do
10
+ let(:name){ "bench_iteration" }
11
+ it{ should be_a(Viiite::Benchmark) }
12
+ end
13
+
14
+ describe "when the file exists in root folder (Symbol)" do
15
+ let(:name){ :bench_iteration }
16
+ it{ should be_a(Viiite::Benchmark) }
17
+ end
18
+
19
+ describe "when the file exists in a sub folder (String)" do
20
+ let(:name){ "Array/bench_sort" }
21
+ it{ should be_a(Viiite::Benchmark) }
22
+ end
23
+
24
+ describe "when the file does not exist" do
25
+ let(:name){ "NotA/Class/bench_non_existing" }
26
+ specify{ lambda{subject}.should raise_error(::Alf::NoSuchDatasetError) }
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+ module Viiite
3
+ class BDB
4
+ describe Immediate, "enumerable" do
5
+
6
+ let(:bdb){ Immediate.new(fixtures_folder+'/bdb') }
7
+
8
+ specify{
9
+ bdb.all?{|tuple|
10
+ File.exists?(tuple[:file])
11
+ }.should be_true
12
+ bdb.to_rel.project([:name]).should eq(Alf::Relation[
13
+ {:name => "bench_iteration"},
14
+ {:name => "Array/bench_sort"}
15
+ ])
16
+ }
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+ module Viiite
3
+ class BDB
4
+ describe Immediate, "pattern" do
5
+
6
+ let(:bdb){ Immediate.new(fixtures_folder+'/bdb', '*_iteration.rb') }
7
+
8
+ specify{
9
+ bdb.all?{|tuple|
10
+ File.exists?(tuple[:file])
11
+ }.should be_true
12
+ bdb.to_rel.project([:name]).should eq(Alf::Relation[
13
+ {:name => "bench_iteration"}
14
+ ])
15
+ }
16
+
17
+ specify{
18
+ lambda {
19
+ Immediate.new(fixtures_folder+'/bdb', 'invalid.{a,b}')
20
+ }.should raise_error(InvalidPattern)
21
+ }
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+ module Viiite
3
+ describe BDB, ".new" do
4
+
5
+ subject{ BDB.new(options) }
6
+
7
+ describe "with default options" do
8
+ let(:options){ {} }
9
+ specify{
10
+ subject.should be_cached
11
+ subject.folder.should eq("benchmarks")
12
+ subject.cache_folder.should eq("benchmarks/.cache")
13
+ subject.cache_mode.should eq("w")
14
+ }
15
+ end
16
+
17
+ describe "with a specific folder" do
18
+ let(:options){ {:folder => "/tmp"} }
19
+ specify{
20
+ subject.should be_cached
21
+ subject.folder.should eq("/tmp")
22
+ subject.cache_folder.should eq("/tmp/.cache")
23
+ }
24
+ end
25
+
26
+ describe "with cache set to false" do
27
+ let(:options){ {:cache => false} }
28
+ specify{
29
+ subject.folder.should eq("benchmarks")
30
+ subject.should_not be_cached
31
+ }
32
+ end
33
+
34
+ describe "with cache set to a specific folder" do
35
+ let(:options){ {:cache => "/tmp"} }
36
+ specify{
37
+ subject.should be_cached
38
+ subject.folder.should eq("benchmarks")
39
+ subject.cache_folder.should eq("/tmp")
40
+ }
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+ module Viiite
3
+ class BDB
4
+ describe Utils, "#bench_file" do
5
+
6
+ let(:utils) { Object.new.extend(Utils) }
7
+ let(:folder){ fixtures_folder }
8
+ subject{ utils.bench_file(folder, file, ext) }
9
+
10
+ describe "on a file in root folder" do
11
+ let(:file){ "bench_iteration" }
12
+ let(:ext) { ".rb" }
13
+ it{ should eq(File.join(folder, "bench_iteration.rb")) }
14
+ end
15
+
16
+ describe "on a file in a sub folder" do
17
+ let(:file){ "Array/bench_sort" }
18
+ let(:ext) { ".rb" }
19
+ it{ should eq(File.join(folder, "Array", "bench_sort.rb")) }
20
+ end
21
+
22
+ end
23
+ end
24
+ end