(b *testing.B)
| 757 | } |
| 758 | |
| 759 | func Benchmark_Parser_Request_Body_File(b *testing.B) { |
| 760 | b.Helper() |
| 761 | |
| 762 | const ( |
| 763 | fileCount = 3 |
| 764 | fileSize = 32 << 10 // 32KB payload per file |
| 765 | ) |
| 766 | |
| 767 | formValues := map[string]string{ |
| 768 | "username": "fiber", |
| 769 | "api_key": "d5942ef5", |
| 770 | } |
| 771 | |
| 772 | fileContents := make([][]byte, fileCount) |
| 773 | for i := range fileContents { |
| 774 | fileContents[i] = bytes.Repeat([]byte{byte('a' + i)}, fileSize) |
| 775 | } |
| 776 | |
| 777 | b.ReportAllocs() |
| 778 | |
| 779 | for i := 0; i < b.N; i++ { |
| 780 | var totalBytes int64 |
| 781 | for _, c := range fileContents { |
| 782 | totalBytes += int64(len(c)) |
| 783 | } |
| 784 | b.SetBytes(totalBytes) |
| 785 | req := newBenchmarkRequest(formValues, fileContents) |
| 786 | if err := parserRequestBodyFile(req); err != nil { |
| 787 | b.Fatalf("parserRequestBodyFile: %v", err) |
| 788 | } |
| 789 | releaseBenchmarkRequest(req) |
| 790 | } |
| 791 | } |
| 792 | |
| 793 | func newBenchmarkRequest(formValues map[string]string, fileContents [][]byte) *Request { |
| 794 | req := &Request{ |
nothing calls this directly
no test coverage detected