(b *testing.B)
| 662 | } |
| 663 | |
| 664 | func 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 | |
| 696 | func BenchmarkFileStorage_KeyPath(b *testing.B) { |
| 697 | runtime.GOMAXPROCS(1) |
nothing calls this directly
no test coverage detected