Permalink
Browse files

+ big cleanup, + more performance/correctness checks

  • Loading branch information...
1 parent 5d263e1 commit 809a97bf496f4126ecbb440171b25a9fb61900c0 @floere committed Nov 9, 2012
Showing with 192 additions and 41 deletions.
  1. +5 −5 server/{lib → }/TODO FOR VERSION 5.txt
  2. +3 −3 server/spec/lib/backends/file/basic_spec.rb
  3. +2 −2 server/spec/lib/backends/file_spec.rb
  4. +3 −3 server/spec/lib/backends/memory/basic_spec.rb
  5. +2 −2 server/spec/lib/backends/memory/json_spec.rb
  6. +2 −2 server/spec/lib/backends/memory/marshal_spec.rb
  7. +3 −3 server/spec/lib/backends/memory_spec.rb
  8. +4 −4 server/spec/lib/backends/sqlite/array_spec.rb
  9. +2 −2 server/spec/lib/backends/sqlite/value_spec.rb
  10. +3 −3 server/spec/lib/backends/sqlite_spec.rb
  11. +4 −4 server/spec/lib/bundle_indexed_spec.rb
  12. +2 −2 server/spec/lib/bundle_spec.rb
  13. 0 server/spec/{ → lib}/category_realtime_spec.rb
  14. +1 −1 server/spec/lib/category_spec.rb
  15. +1 −1 server/spec/lib/index_spec.rb
  16. +1 −1 server/spec/lib/loader_spec.rb
  17. +47 −2 server/spec/{ext → }/performant_spec.rb
  18. +1 −1 server/spec/spec_helper.rb
  19. 0 server/spec/temp/index/test/books/author_exact_configuration.file.json
  20. +1 −0 server/spec/temp/index/test/books/author_exact_configuration.file_mapping.json.memory.json
  21. +1 −0 server/spec/temp/index/test/books/author_exact_configuration.memory.json
  22. BIN server/spec/temp/index/test/books/author_exact_configuration.sqlite3
  23. +1 −0 server/spec/temp/index/test/books/author_exact_inverted.file.json
  24. +1 −0 server/spec/temp/index/test/books/author_exact_inverted.file_mapping.json.memory.json
  25. +1 −0 server/spec/temp/index/test/books/author_exact_inverted.memory.json
  26. BIN server/spec/temp/index/test/books/author_exact_inverted.sqlite3
  27. +1 −0 server/spec/temp/index/test/books/author_exact_realtime.file.json
  28. +1 −0 server/spec/temp/index/test/books/author_exact_realtime.file_mapping.json.memory.json
  29. +1 −0 server/spec/temp/index/test/books/author_exact_realtime.memory.json
  30. BIN server/spec/temp/index/test/books/author_exact_realtime.sqlite3
  31. +1 −0 server/spec/temp/index/test/books/author_exact_similarity.file.json
  32. +1 −0 server/spec/temp/index/test/books/author_exact_similarity.file_mapping.json.memory.json
  33. BIN server/spec/temp/index/test/books/author_exact_similarity.memory.dump
  34. BIN server/spec/temp/index/test/books/author_exact_similarity.sqlite3
  35. +1 −0 server/spec/temp/index/test/books/author_exact_weights.file.json
  36. +1 −0 server/spec/temp/index/test/books/author_exact_weights.file_mapping.json.memory.json
  37. +1 −0 server/spec/temp/index/test/books/author_exact_weights.memory.json
  38. BIN server/spec/temp/index/test/books/author_exact_weights.sqlite3
  39. 0 server/spec/temp/index/test/books/author_partial_configuration.file.json
  40. +1 −0 server/spec/temp/index/test/books/author_partial_configuration.file_mapping.json.memory.json
  41. +1 −0 server/spec/temp/index/test/books/author_partial_configuration.memory.json
  42. BIN server/spec/temp/index/test/books/author_partial_configuration.sqlite3
  43. +1 −0 server/spec/temp/index/test/books/author_partial_inverted.file.json
  44. +1 −0 server/spec/temp/index/test/books/author_partial_inverted.file_mapping.json.memory.json
  45. +1 −0 server/spec/temp/index/test/books/author_partial_inverted.memory.json
  46. BIN server/spec/temp/index/test/books/author_partial_inverted.sqlite3
  47. +1 −0 server/spec/temp/index/test/books/author_partial_realtime.file.json
  48. +1 −0 server/spec/temp/index/test/books/author_partial_realtime.file_mapping.json.memory.json
  49. +1 −0 server/spec/temp/index/test/books/author_partial_realtime.memory.json
  50. BIN server/spec/temp/index/test/books/author_partial_realtime.sqlite3
  51. BIN server/spec/temp/index/test/books/author_partial_similarity.sqlite3
  52. +1 −0 server/spec/temp/index/test/books/author_partial_weights.file.json
  53. +1 −0 server/spec/temp/index/test/books/author_partial_weights.file_mapping.json.memory.json
  54. +1 −0 server/spec/temp/index/test/books/author_partial_weights.memory.json
  55. BIN server/spec/temp/index/test/books/author_partial_weights.sqlite3
  56. 0 server/spec/temp/index/test/books/title_exact_configuration.file.json
  57. +1 −0 server/spec/temp/index/test/books/title_exact_configuration.file_mapping.json.memory.json
  58. +1 −0 server/spec/temp/index/test/books/title_exact_configuration.memory.json
  59. BIN server/spec/temp/index/test/books/title_exact_configuration.sqlite3
  60. +1 −0 server/spec/temp/index/test/books/title_exact_inverted.file.json
  61. +1 −0 server/spec/temp/index/test/books/title_exact_inverted.file_mapping.json.memory.json
  62. +1 −0 server/spec/temp/index/test/books/title_exact_inverted.memory.json
  63. BIN server/spec/temp/index/test/books/title_exact_inverted.sqlite3
  64. +1 −0 server/spec/temp/index/test/books/title_exact_realtime.file.json
  65. +1 −0 server/spec/temp/index/test/books/title_exact_realtime.file_mapping.json.memory.json
  66. +1 −0 server/spec/temp/index/test/books/title_exact_realtime.memory.json
  67. BIN server/spec/temp/index/test/books/title_exact_realtime.sqlite3
  68. BIN server/spec/temp/index/test/books/title_exact_similarity.sqlite3
  69. +1 −0 server/spec/temp/index/test/books/title_exact_weights.file.json
  70. +1 −0 server/spec/temp/index/test/books/title_exact_weights.file_mapping.json.memory.json
  71. +1 −0 server/spec/temp/index/test/books/title_exact_weights.memory.json
  72. BIN server/spec/temp/index/test/books/title_exact_weights.sqlite3
  73. 0 server/spec/temp/index/test/books/title_partial_configuration.file.json
  74. +1 −0 server/spec/temp/index/test/books/title_partial_configuration.file_mapping.json.memory.json
  75. +1 −0 server/spec/temp/index/test/books/title_partial_configuration.memory.json
  76. BIN server/spec/temp/index/test/books/title_partial_configuration.sqlite3
  77. +1 −0 server/spec/temp/index/test/books/title_partial_inverted.file.json
  78. +1 −0 server/spec/temp/index/test/books/title_partial_inverted.file_mapping.json.memory.json
  79. +1 −0 server/spec/temp/index/test/books/title_partial_inverted.memory.json
  80. BIN server/spec/temp/index/test/books/title_partial_inverted.sqlite3
  81. +1 −0 server/spec/temp/index/test/books/title_partial_realtime.file.json
  82. +1 −0 server/spec/temp/index/test/books/title_partial_realtime.file_mapping.json.memory.json
  83. +1 −0 server/spec/temp/index/test/books/title_partial_realtime.memory.json
  84. BIN server/spec/temp/index/test/books/title_partial_realtime.sqlite3
  85. BIN server/spec/temp/index/test/books/title_partial_similarity.sqlite3
  86. +1 −0 server/spec/temp/index/test/books/title_partial_weights.file.json
  87. +1 −0 server/spec/temp/index/test/books/title_partial_weights.file_mapping.json.memory.json
  88. +1 −0 server/spec/temp/index/test/books/title_partial_weights.memory.json
  89. BIN server/spec/temp/index/test/books/title_partial_weights.sqlite3
  90. +2 −0 server/spec/temp/index/test/exact_first/text.prepared.txt
  91. +1 −0 server/spec/temp/index/test/exact_first/text_exact_configuration.memory.json
  92. +1 −0 server/spec/temp/index/test/exact_first/text_exact_inverted.memory.json
  93. +1 −0 server/spec/temp/index/test/exact_first/text_exact_realtime.memory.json
  94. +1 −0 server/spec/temp/index/test/exact_first/text_exact_weights.memory.json
  95. +1 −0 server/spec/temp/index/test/exact_first/text_partial_configuration.memory.json
  96. +1 −0 server/spec/temp/index/test/exact_first/text_partial_inverted.memory.json
  97. +1 −0 server/spec/temp/index/test/exact_first/text_partial_realtime.memory.json
  98. +1 −0 server/spec/temp/index/test/exact_first/text_partial_weights.memory.json
  99. +4 −0 server/spec/temp/index/test/index1/text.prepared.txt
  100. +1 −0 server/spec/temp/index/test/index1/text_exact_configuration.memory.json
  101. +1 −0 server/spec/temp/index/test/index1/text_exact_inverted.memory.json
  102. +1 −0 server/spec/temp/index/test/index1/text_exact_realtime.memory.json
  103. +1 −0 server/spec/temp/index/test/index1/text_exact_weights.memory.json
  104. +1 −0 server/spec/temp/index/test/index1/text_partial_configuration.memory.json
  105. +1 −0 server/spec/temp/index/test/index1/text_partial_inverted.memory.json
  106. +1 −0 server/spec/temp/index/test/index1/text_partial_realtime.memory.json
  107. +1 −0 server/spec/temp/index/test/index1/text_partial_weights.memory.json
  108. +4 −0 server/spec/temp/index/test/index2/text.prepared.txt
  109. +1 −0 server/spec/temp/index/test/index2/text_exact_configuration.memory.json
  110. +1 −0 server/spec/temp/index/test/index2/text_exact_inverted.memory.json
  111. +1 −0 server/spec/temp/index/test/index2/text_exact_realtime.memory.json
  112. +1 −0 server/spec/temp/index/test/index2/text_exact_weights.memory.json
  113. +1 −0 server/spec/temp/index/test/index2/text_partial_configuration.memory.json
  114. +1 −0 server/spec/temp/index/test/index2/text_partial_inverted.memory.json
  115. +1 −0 server/spec/temp/index/test/index2/text_partial_realtime.memory.json
  116. +1 −0 server/spec/temp/index/test/index2/text_partial_weights.memory.json
  117. 0 server/spec/temp/index/test/some_index/some_category_some_bundle_configuration.sqlite3
  118. 0 server/spec/temp/index/test/some_index/some_category_some_bundle_inverted.sqlite3
  119. 0 server/spec/temp/index/test/some_index/some_category_some_bundle_similarity.sqlite3
  120. 0 server/spec/temp/index/test/some_index/some_category_some_bundle_weights.sqlite3
  121. +1 −0 server/spec/temp/index/test/some_index/some_category_some_name_configuration.memory.json
  122. BIN server/spec/temp/index/test/some_index/some_category_some_name_configuration.sqlite3
  123. +1 −0 server/spec/temp/index/test/some_index/some_category_some_name_inverted.memory.json
  124. BIN server/spec/temp/index/test/some_index/some_category_some_name_inverted.sqlite3
  125. +1 −0 server/spec/temp/index/test/some_index/some_category_some_name_realtime.memory.json
  126. BIN server/spec/temp/index/test/some_index/some_category_some_name_realtime.sqlite3
  127. BIN server/spec/temp/index/test/some_index/some_category_some_name_similarity.memory.dump
  128. BIN server/spec/temp/index/test/some_index/some_category_some_name_similarity.sqlite3
  129. +1 −0 server/spec/temp/index/test/some_index/some_category_some_name_weights.memory.json
  130. BIN server/spec/temp/index/test/some_index/some_category_some_name_weights.sqlite3
  131. +3 −0 server/spec/temp/index/test/sorted/first.prepared.txt
  132. +1 −0 server/spec/temp/index/test/sorted/first_exact_configuration.memory.json
  133. +1 −0 server/spec/temp/index/test/sorted/first_exact_inverted.memory.json
  134. +1 −0 server/spec/temp/index/test/sorted/first_exact_realtime.memory.json
  135. +1 −0 server/spec/temp/index/test/sorted/first_exact_weights.memory.json
  136. +1 −0 server/spec/temp/index/test/sorted/first_partial_configuration.memory.json
  137. +1 −0 server/spec/temp/index/test/sorted/first_partial_inverted.memory.json
  138. +1 −0 server/spec/temp/index/test/sorted/first_partial_realtime.memory.json
  139. +1 −0 server/spec/temp/index/test/sorted/first_partial_weights.memory.json
  140. +3 −0 server/spec/temp/index/test/sorted/last.prepared.txt
  141. +1 −0 server/spec/temp/index/test/sorted/last_exact_configuration.memory.json
  142. +1 −0 server/spec/temp/index/test/sorted/last_exact_inverted.memory.json
  143. +1 −0 server/spec/temp/index/test/sorted/last_exact_realtime.memory.json
  144. +1 −0 server/spec/temp/index/test/sorted/last_exact_weights.memory.json
  145. +1 −0 server/spec/temp/index/test/sorted/last_partial_configuration.memory.json
  146. +1 −0 server/spec/temp/index/test/sorted/last_partial_inverted.memory.json
  147. +1 −0 server/spec/temp/index/test/sorted/last_partial_realtime.memory.json
  148. +1 −0 server/spec/temp/index/test/sorted/last_partial_weights.memory.json
@@ -1,13 +1,13 @@
TODO s for version 5
====================
-Loggers as modules
-------------------
+Loggers as modules?
+-------------------
Picky.logger = STDOUT
-Picky.logger = Logger.new('log/search.log')
-Picky.logger = STDOUT.extend Picky::Loggers::Silent # <= Problematic?
-Picky.logger = Logger.new('log/search.log').extend Picky::Loggers::Verbose
+Picky.logger = Logger.new('log/picky.log')
+Picky.logger = STDOUT.extend Picky::Loggers::Silent # <= Problematic.
+Picky.logger = Logger.new('log/picky.log').extend Picky::Loggers::Verbose
...
def logger= loggy_thing
@@ -3,7 +3,7 @@
describe Picky::Backends::File::Basic do
context 'without options' do
- let(:basic) { described_class.new 'some/cache/path/to/file' }
+ let(:basic) { described_class.new 'spec/temp/some/cache/path/to/file' }
describe 'empty' do
it 'returns the container that is used for indexing' do
@@ -19,14 +19,14 @@
describe 'to_s' do
it 'returns the cache path with the default file extension' do
- basic.to_s.should == 'Picky::Backends::File::Basic(some/cache/path/to/file.file.index,some/cache/path/to/file.file_mapping.index.memory.json)'
+ basic.to_s.should == 'Picky::Backends::File::Basic(spec/temp/some/cache/path/to/file.file.index,spec/temp/some/cache/path/to/file.file_mapping.index.memory.json)'
end
end
end
context 'with options' do
let(:basic) do
- described_class.new 'some/cache/path/to/file',
+ described_class.new 'spec/temp/some/cache/path/to/file',
empty: [],
initial: []
end
@@ -21,7 +21,7 @@
# ].each do |type, kind|
# it "creates and returns a(n) #{type} index" do
# @backend.send(:"create_#{type}",
- # stub(type, :index_path => "spec/test_directory/index/test/some_index/some_category_some_bundle_#{type}")
+ # stub(type, :index_path => "spec/temp/index/test/some_index/some_category_some_bundle_#{type}")
# ).should be_kind_of(kind)
# end
# end
@@ -44,7 +44,7 @@
].each do |type, kind|
it "creates and returns a(n) #{type} index" do
@backend.send(:"create_#{type}",
- stub(type, :index_path => "spec/test_directory/index/test/some_index/some_category_some_bundle_#{type}")
+ stub(type, :index_path => "spec/temp/index/test/some_index/some_category_some_bundle_#{type}")
).should be_kind_of(kind)
end
end
@@ -3,7 +3,7 @@
describe Picky::Backends::Memory::Basic do
context 'without options' do
- let(:basic) { described_class.new 'some/cache/path/to/file' }
+ let(:basic) { described_class.new 'spec/temp/some/cache/path/to/file' }
describe 'empty' do
it 'returns the container that is used for indexing' do
@@ -19,14 +19,14 @@
describe 'to_s' do
it 'returns the cache path with the default file extension' do
- basic.to_s.should == 'Picky::Backends::Memory::Basic(some/cache/path/to/file.memory.index)'
+ basic.to_s.should == 'Picky::Backends::Memory::Basic(spec/temp/some/cache/path/to/file.memory.index)'
end
end
end
context 'with options' do
let(:basic) do
- described_class.new 'some/cache/path/to/file',
+ described_class.new 'spec/temp/some/cache/path/to/file',
empty: [],
initial: []
end
@@ -3,7 +3,7 @@
describe Picky::Backends::Memory::JSON do
context 'hash-based indexes' do
- let(:json) { described_class.new 'some/cache/path/to/file' }
+ let(:json) { described_class.new 'spec/temp/some/cache/path/to/file' }
describe 'extension' do
it 'is correct' do
@@ -37,7 +37,7 @@
describe 'to_s' do
it 'returns the cache path with the default file extension' do
- json.to_s.should == 'Picky::Backends::Memory::JSON(some/cache/path/to/file.memory.json)'
+ json.to_s.should == 'Picky::Backends::Memory::JSON(spec/temp/some/cache/path/to/file.memory.json)'
end
end
end
@@ -3,7 +3,7 @@
describe Picky::Backends::Memory::Marshal do
context 'hash-based indexes' do
- let(:marshal) { described_class.new 'some/cache/path/to/file' }
+ let(:marshal) { described_class.new 'spec/temp/some/cache/path/to/file' }
describe 'extension' do
it 'is correct' do
@@ -37,7 +37,7 @@
describe 'to_s' do
it 'returns the cache path with the default file extension' do
- marshal.to_s.should == 'Picky::Backends::Memory::Marshal(some/cache/path/to/file.memory.dump)'
+ marshal.to_s.should == 'Picky::Backends::Memory::Marshal(spec/temp/some/cache/path/to/file.memory.dump)'
end
end
end
@@ -21,7 +21,7 @@
# ].each do |type, kind|
# it "creates and returns a(n) #{type} index" do
# @backend.send(:"create_#{type}",
- # stub(type, :index_path => "spec/test_directory/index/test/some_index/some_category_some_bundle_#{type}")
+ # stub(type, :index_path => "spec/temp/index/test/some_index/some_category_some_bundle_#{type}")
# ).should be_kind_of(kind)
# end
# end
@@ -47,7 +47,7 @@
# ].each do |type, kind|
# it "creates and returns a(n) #{type} index" do
# to_a_able_stub = Object.new
- # to_a_able_stub.stub! :index_path => "spec/test_directory/index/test/some_index/some_category_some_bundle_#{type}"
+ # to_a_able_stub.stub! :index_path => "spec/temp/index/test/some_index/some_category_some_bundle_#{type}"
# @backend.send(:"create_#{type}", to_a_able_stub).should be_kind_of(kind)
# end
# end
@@ -70,7 +70,7 @@
].each do |type, kind|
it "creates and returns a(n) #{type} index" do
@backend.send(:"create_#{type}",
- stub(type, :index_path => "spec/test_directory/index/test/some_index/some_category_some_bundle_#{type}")
+ stub(type, :index_path => "spec/temp/index/test/some_index/some_category_some_bundle_#{type}")
).should be_kind_of(kind)
end
end
@@ -5,7 +5,7 @@
describe Picky::Backends::SQLite::Array do
context 'hash-based indexes' do
- let(:db) { described_class.new 'some/cache/path/to/file' }
+ let(:db) { described_class.new 'spec/temp/some/cache/path/to/file' }
describe 'dump' do
it 'delegates to the given hash' do
@@ -67,13 +67,13 @@
describe 'to_s' do
it 'returns the cache path with the default file extension' do
- db.to_s.should == 'Picky::Backends::SQLite::Array(some/cache/path/to/file.sqlite3)'
+ db.to_s.should == 'Picky::Backends::SQLite::Array(spec/temp/some/cache/path/to/file.sqlite3)'
end
end
end
context 'hash-based indexes' do
- let(:db) { described_class.new 'some/cache/path/to/file', realtime: true }
+ let(:db) { described_class.new 'spec/temp/some/cache/path/to/file', realtime: true }
describe 'dump' do
it 'delegates to the given hash' do
@@ -135,7 +135,7 @@
describe 'to_s' do
it 'returns the cache path with the default file extension' do
- db.to_s.should == 'Picky::Backends::SQLite::Array(some/cache/path/to/file.sqlite3)'
+ db.to_s.should == 'Picky::Backends::SQLite::Array(spec/temp/some/cache/path/to/file.sqlite3)'
end
end
end
@@ -5,7 +5,7 @@
describe Picky::Backends::SQLite::Value do
context 'hash-based indexes' do
- let(:db) { described_class.new 'some/cache/path/to/file' }
+ let(:db) { described_class.new 'spec/temp/some/cache/path/to/file' }
describe 'dump' do
it 'delegates to the given hash' do
@@ -67,7 +67,7 @@
describe 'to_s' do
it 'returns the cache path with the default file extension' do
- db.to_s.should == 'Picky::Backends::SQLite::Value(some/cache/path/to/file.sqlite3)'
+ db.to_s.should == 'Picky::Backends::SQLite::Value(spec/temp/some/cache/path/to/file.sqlite3)'
end
end
end
@@ -23,7 +23,7 @@
# ].each do |type, kind|
# it "creates and returns a(n) #{type} index" do
# @backend.send(:"create_#{type}",
- # stub(type, :index_path => "spec/test_directory/index/test/some_index/some_category_some_bundle_#{type}")
+ # stub(type, :index_path => "spec/temp/index/test/some_index/some_category_some_bundle_#{type}")
# ).should be_kind_of(kind)
# end
# end
@@ -49,7 +49,7 @@
# ].each do |type, kind|
# it "creates and returns a(n) #{type} index" do
# to_a_able_stub = Object.new
- # to_a_able_stub.stub! :index_path => "spec/test_directory/index/test/some_index/some_category_some_bundle_#{type}"
+ # to_a_able_stub.stub! :index_path => "spec/temp/index/test/some_index/some_category_some_bundle_#{type}"
# @backend.send(:"create_#{type}", to_a_able_stub).should be_kind_of(kind)
# end
# end
@@ -72,7 +72,7 @@
].each do |type, kind|
it "creates and returns a(n) #{type} index" do
@backend.send(:"create_#{type}",
- stub(type, :index_path => "spec/test_directory/index/test/some_index/some_category_some_bundle_#{type}")
+ stub(type, :index_path => "spec/temp/index/test/some_index/some_category_some_bundle_#{type}")
).should be_kind_of(kind)
end
end
@@ -119,7 +119,7 @@
it "uses the right file" do
MultiJson.stub! :decode
- File.should_receive(:open).once.with 'spec/test_directory/index/test/some_index/some_category_some_name_inverted.memory.json', 'r'
+ File.should_receive(:open).once.with 'spec/temp/index/test/some_index/some_category_some_name_inverted.memory.json', 'r'
@bundle.load_inverted
end
@@ -128,7 +128,7 @@
it "uses the right file" do
MultiJson.stub! :decode
- File.should_receive(:open).once.with 'spec/test_directory/index/test/some_index/some_category_some_name_weights.memory.json', 'r'
+ File.should_receive(:open).once.with 'spec/temp/index/test/some_index/some_category_some_name_weights.memory.json', 'r'
@bundle.load_weights
end
@@ -137,7 +137,7 @@
it "uses the right file" do
Marshal.stub! :load
- File.should_receive(:open).once.with 'spec/test_directory/index/test/some_index/some_category_some_name_similarity.memory.dump', 'r:binary'
+ File.should_receive(:open).once.with 'spec/temp/index/test/some_index/some_category_some_name_similarity.memory.dump', 'r:binary'
@bundle.load_similarity
end
@@ -146,7 +146,7 @@
it "uses the right file" do
MultiJson.stub! :decode
- File.should_receive(:open).once.with 'spec/test_directory/index/test/some_index/some_category_some_name_configuration.memory.json', 'r'
+ File.should_receive(:open).once.with 'spec/temp/index/test/some_index/some_category_some_name_configuration.memory.json', 'r'
@bundle.load_configuration
end
@@ -22,10 +22,10 @@
describe 'index_path' do
it 'is correct' do
- bundle.index_path(:some_type).should == 'spec/test_directory/index/test/some_index/some_category_some_name_some_type'
+ bundle.index_path(:some_type).should == 'spec/temp/index/test/some_index/some_category_some_name_some_type'
end
it 'is correct' do
- bundle.index_path.should == 'spec/test_directory/index/test/some_index/some_category_some_name'
+ bundle.index_path.should == 'spec/temp/index/test/some_index/some_category_some_name'
end
end
@@ -27,7 +27,7 @@
context 'directories' do
let(:category) { described_class.new :some_category, index }
it 'is correct' do
- category.prepared_index_path.should == 'spec/test_directory/index/test/some_index/some_category'
+ category.prepared_index_path.should == 'spec/temp/index/test/some_index/some_category'
end
end
@@ -58,7 +58,7 @@
describe 'directory' do
it 'is correct' do
- api.directory.should == 'spec/test_directory/index/test/some_index_name'
+ api.directory.should == 'spec/temp/index/test/some_index_name'
end
end
@@ -18,7 +18,7 @@
describe 'load_application' do
it 'does ok' do
- Kernel.should_receive(:load).once.with 'spec/test_directory/app.rb'
+ Kernel.should_receive(:load).once.with 'spec/temp/app.rb'
lambda { described_class.load_application }.should_not raise_error
end
@@ -36,13 +36,15 @@
it "should be optimal for 2 small arrays of 50/10_000" do
arys = [(1..50).to_a, (10_000..20_000).to_a << 7]
- # brute force
+ # Brute force.
+ #
performance_of { Performant::Array.memory_efficient_intersect(arys) }.should < 0.001
end
it "should be optimal for 2 small arrays of 50/10_000" do
arys = [(1..50).to_a, (10_000..20_000).to_a << 7]
# &
+ #
performance_of do
arys.inject(arys.shift.dup) do |total, ary|
total & arys
@@ -75,13 +77,56 @@
it "should be optimal for 2 small arrays of 50/10_000" do
arys = [(:'1'..:'50').to_a, (:'10_000'..:'20_000').to_a]
- # brute force
+ # Brute force.
+ #
performance_of { Performant::Array.memory_efficient_intersect(arys) }.should < 0.001
end
it "should be optimal for 2 small arrays of 50/10_000" do
arys = [(:'1'..:'50').to_a, (:'10_000'..:'20_000').to_a << 7]
# &
+ #
+ performance_of do
+ arys.inject(arys.shift.dup) do |total, ary|
+ total & arys
+ end
+ end.should < 0.0015
+ end
+ end
+
+ describe "memory_efficient_intersect with strings" do
+ it "should intersect empty arrays correctly" do
+ arys = [['c','d'], ['a','b','c'], []]
+
+ Performant::Array.memory_efficient_intersect(arys).should == []
+ end
+ it "should handle intermediate empty results correctly" do
+ arys = [['e','d'], ['a','b','c'], ['c','d','e','h','i']]
+
+ Performant::Array.memory_efficient_intersect(arys).should == []
+ end
+ it "should intersect correctly" do
+ arys = [['c','d'], ['a','b','c'], ['c','d','e','h','i']]
+
+ Performant::Array.memory_efficient_intersect(arys).should == ['c']
+ end
+ it "should intersect many arrays" do
+ arys = [['c','d','e','f','g'], ['a','b','c','e','f','g'], ['c','d','e','f','g','h','i'], ['a','b','c','d','e','f','g','h','i','j'], ['b','c','e','f','g','s'], ['a','b','c','d','e','f','g','h','i','j'], ['b','c','e','f','g','s']]
+
+ Performant::Array.memory_efficient_intersect(arys).should == ['c','e','f','g']
+ end
+ it "should be optimal for 2 small arrays of 50/10_000" do
+ arys = [('1'..'50').to_a, ('10000'..'20000').to_a]
+
+ # Brute force - note that it is slower than the Symbols/Integers version.
+ #
+ performance_of { Performant::Array.memory_efficient_intersect(arys) }.should < 0.0015
+ end
+ it "should be optimal for 2 small arrays of 50/10_000" do
+ arys = [('1'..'50').to_a, ('10000'..'20000').to_a << 7]
+
+ # &
+ #
performance_of do
arys.inject(arys.shift.dup) do |total, ary|
total & arys
@@ -14,7 +14,7 @@
# Set some spec preconditions.
#
-Picky.root = 'spec/test_directory'
+Picky.root = 'spec/temp'
Picky.logger = Picky::Loggers::Silent.new
begin
Oops, something went wrong.

0 comments on commit 809a97b

Please sign in to comment.