spec/functional/terminate_early_spec.rb in picky-3.6.15 vs spec/functional/terminate_early_spec.rb in picky-3.6.16

- old
+ new

@@ -77,16 +77,22 @@ try.search('hello', 13, 4).ids.should == [2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2] try.search('hello', 13, 8).ids.should == [4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4] try.search('hello', 13, 12).ids.should == [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1] try.search('hello', 13, 16).ids.should == [2, 1, 6, 5, 4, 3, 2, 1] - try.search('hello', 13).to_hash[:allocations].size.should == 3 - try.search('hello', 13, 4).to_hash[:allocations].size.should == 3 + try.search('hello', 13).to_hash[:allocations].size.should == 4 + try.search('hello', 13, 4).to_hash[:allocations].size.should == 4 try.search('hello', 13, 8).to_hash[:allocations].size.should == 4 try.search('hello', 13, 12).to_hash[:allocations].size.should == 4 try.search('hello', 13, 16).to_hash[:allocations].size.should == 4 + try.search('hello', 13).allocations.map(&:count).should == [6, 6, 6, 6] + try.search('hello', 13, 4).allocations.map(&:count).should == [6, 6, 6, 6] + try.search('hello', 13, 8).allocations.map(&:count).should == [6, 6, 6, 6] + try.search('hello', 13, 12).allocations.map(&:count).should == [6, 6, 6, 6] + try.search('hello', 13, 16).allocations.map(&:count).should == [6, 6, 6, 6] + try = Picky::Search.new index do terminate_early with_extra_allocations: 2 end try.search('hello').ids.should == [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5] @@ -104,16 +110,46 @@ try.search('hello', 1, 12).ids.should == [6] try.search('hello', 1, 16).ids.should == [2] try.search('hello', 1).to_hash[:allocations].size.should == 2 try.search('hello', 1, 4).to_hash[:allocations].size.should == 2 - try.search('hello', 1, 8).to_hash[:allocations].size.should == 2 - try.search('hello', 1, 12).to_hash[:allocations].size.should == 3 - try.search('hello', 1, 16).to_hash[:allocations].size.should == 3 + try.search('hello', 1, 8).to_hash[:allocations].size.should == 3 + try.search('hello', 1, 12).to_hash[:allocations].size.should == 4 + try.search('hello', 1, 16).to_hash[:allocations].size.should == 4 try.search('hello', 1, 20).to_hash[:allocations].size.should == 4 try.search('hello', 1, 24).to_hash[:allocations].size.should == 4 + try.search('hello', 1).allocations.map(&:count).should == [6, 6, nil, nil] + try.search('hello', 1, 4).allocations.map(&:count).should == [6, 6, nil, nil] + try.search('hello', 1, 8).allocations.map(&:count).should == [6, 6, 6, nil] + try.search('hello', 1, 12).allocations.map(&:count).should == [6, 6, 6, 6] + try.search('hello', 1, 16).allocations.map(&:count).should == [6, 6, 6, 6] + try.search('hello', 1, 20).allocations.map(&:count).should == [6, 6, 6, 6] + try.search('hello', 1, 24).allocations.map(&:count).should == [6, 6, 6, 6] + + try.search('hello', 1, 0).to_hash.should == { + :allocations => [ + [:terminate_early, 1.792, 6, [[:text1, "hello", "hello"]], [6]], + [:terminate_early, 1.792, 6, [[:text2, "hello", "hello"]], []] + ], + :offset => 0, + :duration => anything, + :total => 12 + } + + try.search('hello', 1, 12).to_hash.should == { + :allocations => [ + [:terminate_early, 1.792, 6, [[:text1, "hello", "hello"]], []], + [:terminate_early, 1.792, 6, [[:text2, "hello", "hello"]], []], + [:terminate_early, 1.792, 6, [[:text3, "hello", "hello"]], [6]], + [:terminate_early, 1.792, 6, [[:text4, "hello", "hello"]], []] + ], + :offset => 12, + :duration => anything, + :total => 24 + } + GC.start try_slow = Picky::Search.new index slow = performance_of do try_slow.search 'hello' @@ -146,10 +182,10 @@ terminate_early end fast = performance_of do try_fast.search 'hello hello hello' end - (slow/fast).should >= 1.8 + (slow/fast).should >= 1.7 try_slow = Picky::Search.new index slow = performance_of do try_slow.search 'hello hello hello hello' end \ No newline at end of file