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

Function BenchmarkFileStorage_Read

internal/caches/storage_file_test.go:664–694  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

662}
663
664func BenchmarkFileStorage_Read(b *testing.B) {
665 runtime.GOMAXPROCS(1)
666
667 _ = utils.SetRLimit(1 << 20)
668
669 var storage = NewFileStorage(&serverconfigs.HTTPCachePolicy{
670 Id: 1,
671 IsOn: true,
672 Options: map[string]interface{}{
673 "dir": Tea.Root + "/caches",
674 },
675 })
676
677 defer storage.Stop()
678
679 err := storage.Init()
680 if err != nil {
681 b.Fatal(err)
682 }
683 for i := 0; i < b.N; i++ {
684 reader, err := storage.OpenReader("my-key", false, false)
685 if err != nil {
686 b.Fatal(err)
687 }
688 buf := make([]byte, 1024)
689 _ = reader.ReadBody(buf, func(n int) (goNext bool, err error) {
690 return true, nil
691 })
692 _ = reader.Close()
693 }
694}
695
696func BenchmarkFileStorage_KeyPath(b *testing.B) {
697 runtime.GOMAXPROCS(1)

Callers

nothing calls this directly

Calls 7

SetRLimitFunction · 0.92
NewFileStorageFunction · 0.85
StopMethod · 0.65
InitMethod · 0.65
OpenReaderMethod · 0.65
ReadBodyMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected