spec/functional/terminate_early_spec.rb in picky-3.6.13 vs spec/functional/terminate_early_spec.rb in picky-3.6.14

- old
+ new

@@ -21,10 +21,13 @@ index.add thing.new(6, 'hello', 'hello', 'hello', 'hello') try = Picky::Search.new index 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] + try = Picky::Search.new index + try.search('hello', 30).ids.should == [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1] + try = Picky::Search.new index do terminate_early end try.search('hello', 3).ids.should == [6, 5, 4] @@ -35,25 +38,37 @@ try = Picky::Search.new index do terminate_early with_extra_allocations: 0 end try.search('hello', 9).ids.should == [6, 5, 4, 3, 2, 1, 6, 5, 4] + try.search('hello', 9, 4).ids.should == [2, 1, 6, 5, 4, 3, 2, 1, 6] + try.search('hello', 9, 7).ids.should == [5, 4, 3, 2, 1, 6, 5, 4, 3] + try.search('hello', 9, 10).ids.should == [2, 1, 6, 5, 4, 3, 2, 1, 6] + try.search('hello', 9, 13).ids.should == [5, 4, 3, 2, 1, 6, 5, 4, 3] + try.search('hello', 9, 16).ids.should == [2, 1, 6, 5, 4, 3, 2, 1] + try.search('hello', 9, 19).ids.should == [5, 4, 3, 2, 1] + try.search('hello', 9, 22).ids.should == [2, 1] + try.search('hello', 9, 25).ids.should == [] try = Picky::Search.new index do terminate_early 0 end - try.search('hello').ids.should == [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1] + 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] try = Picky::Search.new index do terminate_early with_extra_allocations: 0 end - try.search('hello').ids.should == [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1] + 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] try = Picky::Search.new index do terminate_early 2 end try.search('hello', 13).ids.should == [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6] + 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 = 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] @@ -61,20 +76,57 @@ try = Picky::Search.new index do terminate_early with_extra_allocations: 1234 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] + GC.start + + try_slow = Picky::Search.new index slow = performance_of do - try.search 'hello' + try_slow.search 'hello' end + try_fast = Picky::Search.new index do + terminate_early + end + fast = performance_of do + try_fast.search 'hello' + end + (slow/fast).should >= 1.1 - try = Picky::Search.new index do + try_slow = Picky::Search.new index + slow = performance_of do + try_slow.search 'hello hello' + end + try_fast = Picky::Search.new index do terminate_early end fast = performance_of do - try.search 'hello' + try_fast.search 'hello hello' end - - (slow/fast).should + (slow/fast).should >= 1.4 + + try_slow = Picky::Search.new index + slow = performance_of do + try_slow.search 'hello hello hello' + end + try_fast = Picky::Search.new index do + terminate_early + end + fast = performance_of do + try_fast.search 'hello hello hello' + end + (slow/fast).should >= 1.8 + + try_slow = Picky::Search.new index + slow = performance_of do + try_slow.search 'hello hello hello hello' + end + try_fast = Picky::Search.new index do + terminate_early + end + fast = performance_of do + try_fast.search 'hello hello hello hello' + end + (slow/fast).should >= 2.0 end end \ No newline at end of file