MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / BenchmarkIPList_Sort

Function BenchmarkIPList_Sort

internal/iplibrary/ip_list_test.go:473–495  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

471}
472
473func BenchmarkIPList_Sort(b *testing.B) {
474 var list = iplibrary.NewIPList()
475 for i := 0; i < 1_000_000; i++ {
476 var item = &iplibrary.IPItem{
477 Id: uint64(i),
478 IPFrom: iputils.ToBytes(strconv.Itoa(rands.Int(0, 255)) + "." + strconv.Itoa(rands.Int(0, 255)) + ".0.1"),
479 ExpiredAt: time.Now().Unix() + 60,
480 }
481
482 if i%100 == 0 {
483 item.IPTo = iputils.ToBytes(strconv.Itoa(rands.Int(0, 255)) + "." + strconv.Itoa(rands.Int(0, 255)) + ".0.1")
484 }
485
486 list.AddDelay(item)
487 }
488
489 b.ResetTimer()
490 b.RunParallel(func(pb *testing.PB) {
491 for pb.Next() {
492 list.Sort()
493 }
494 })
495}

Callers

nothing calls this directly

Calls 5

NewIPListFunction · 0.92
UnixMethod · 0.80
AddDelayMethod · 0.80
NextMethod · 0.80
SortMethod · 0.80

Tested by

no test coverage detected