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

Function BenchmarkFileHeader_Encode

internal/utils/bfs/file_header_test.go:397–432  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

395}
396
397func BenchmarkFileHeader_Encode(b *testing.B) {
398 runtime.GOMAXPROCS(12)
399
400 b.RunParallel(func(pb *testing.PB) {
401 for pb.Next() {
402 var header = &bfs.FileHeader{
403 Version: 1,
404 Status: 200,
405 ModifiedAt: rand.Int63(),
406 BodySize: rand.Int63(),
407 BodyBlocks: []bfs.BlockInfo{},
408 }
409 var offset int64
410 for {
411 var end = offset + 16<<10
412 if end > 2<<20 {
413 break
414 }
415
416 header.BodyBlocks = append(header.BodyBlocks, bfs.BlockInfo{
417 BFileOffsetFrom: offset + int64(rand.Int()%1000000),
418 BFileOffsetTo: end + int64(rand.Int()%1000000),
419 })
420
421 offset = end
422 }
423
424 var hash = bfs.Hash("123456")
425
426 _, err := header.Encode(hash)
427 if err != nil {
428 b.Fatal(err)
429 }
430 }
431 })
432}

Callers

nothing calls this directly

Calls 3

HashFunction · 0.92
NextMethod · 0.80
EncodeMethod · 0.65

Tested by

no test coverage detected