@@ -373,7 +373,7 @@ func BenchmarkListIntersectCompressBin(b *testing.B) {
373373 for _ , r := range rs {
374374 sz1 := sz
375375 sz2 := int (float64 (sz ) * r )
376- if sz2 > 1000000 || sz2 == 0 {
376+ if sz2 > 10000000 || sz2 == 0 {
377377 break
378378 }
379379
@@ -389,8 +389,18 @@ func BenchmarkListIntersectCompressBin(b *testing.B) {
389389 sort .Slice (v1 , func (i , j int ) bool { return v1 [i ] < v1 [j ] })
390390
391391 dst2 := & pb.List {}
392+ dst1 := & pb.List {}
392393 compressedUids := codec .Encode (v1 , 256 )
393394
395+ b .Run (fmt .Sprintf ("linJump:IntersectWith:ratio=%v:size=%d:overlap=%.2f:" , r , sz , overlap ),
396+ func (b * testing.B ) {
397+ for k := 0 ; k < b .N ; k ++ {
398+ dec := codec.Decoder {Pack : compressedUids }
399+ dec .Seek (0 , codec .SeekStart )
400+ IntersectCompressedWithLinJump (& dec , u1 , & dst1 .Uids )
401+ }
402+ })
403+
394404 b .Run (fmt .Sprintf ("compressed:IntersectWith:ratio=%v:size=%d:overlap=%.2f:" , r , sz , overlap ),
395405 func (b * testing.B ) {
396406 for k := 0 ; k < b .N ; k ++ {
@@ -399,7 +409,6 @@ func BenchmarkListIntersectCompressBin(b *testing.B) {
399409 IntersectCompressedWithBin (& dec , u1 , & dst2 .Uids )
400410 }
401411 })
402- fmt .Println ()
403412
404413 codec .FreePack (compressedUids )
405414 }
@@ -493,6 +502,43 @@ func sortUint64(nums []uint64) {
493502 sort .Slice (nums , func (i , j int ) bool { return nums [i ] < nums [j ] })
494503}
495504
505+ func fillNumsDiff (N1 , N2 , N3 int ) ([]uint64 , []uint64 , []uint64 ) {
506+ rand .Seed (time .Now ().UnixNano ())
507+
508+ commonNums := make ([]uint64 , N1 )
509+ blockNums := make ([]uint64 , N1 + N2 )
510+ otherNums := make ([]uint64 , N1 + N3 )
511+ allC := make (map [uint64 ]bool )
512+
513+ for i := 0 ; i < N1 ; i ++ {
514+ val := rand .Uint64 () % 1000
515+ commonNums [i ] = val
516+ blockNums [i ] = val
517+ otherNums [i ] = val
518+ allC [val ] = true
519+ }
520+
521+ for i := N1 ; i < N1 + N2 ; i ++ {
522+ val := rand .Uint64 () % 1000
523+ blockNums [i ] = val
524+ allC [val ] = true
525+ }
526+
527+ for i := N1 ; i < N1 + N3 ; i ++ {
528+ val := rand .Uint64 ()
529+ for ok := true ; ok ; _ , ok = allC [val ] {
530+ val = rand .Uint64 () % 1000
531+ }
532+ otherNums [i ] = val
533+ }
534+
535+ sortUint64 (commonNums )
536+ sortUint64 (blockNums )
537+ sortUint64 (otherNums )
538+
539+ return commonNums , blockNums , otherNums
540+ }
541+
496542func fillNums (N1 , N2 int ) ([]uint64 , []uint64 , []uint64 ) {
497543 rand .Seed (time .Now ().UnixNano ())
498544
@@ -545,12 +591,12 @@ func TestIntersectCompressedWithLinJump(t *testing.T) {
545591}
546592
547593func TestIntersectCompressedWithBin (t * testing.T ) {
548- lengths := []int {0 , 1 , 3 , 11 , 100 }
594+ // lengths := []int{0, 1, 3, 11, 100, 500, 1000 }
549595
550- for _ , N1 := range lengths {
551- for _ , N2 := range lengths {
596+ for _ , N1 := range [] int { 11 } {
597+ for _ , N2 := range [] int { 3 } {
552598 // Intersection of blockNums and otherNums is commonNums.
553- commonNums , blockNums , otherNums := fillNums ( N1 , N2 )
599+ commonNums , blockNums , otherNums := fillNumsDiff ( N1 / 10 , N1 , N2 )
554600
555601 enc := codec.Encoder {BlockSize : 10 }
556602 for _ , num := range blockNums {
@@ -570,7 +616,7 @@ func TestIntersectCompressedWithBin(t *testing.T) {
570616}
571617
572618func TestIntersectCompressedWithBinMissingSize (t * testing.T ) {
573- lengths := []int {0 , 1 , 3 , 11 , 100 }
619+ lengths := []int {0 , 1 , 3 , 11 , 100 , 500 , 1000 }
574620
575621 for _ , N1 := range lengths {
576622 for _ , N2 := range lengths {
0 commit comments