MCPcopy
hub / github.com/gofiber/fiber / Benchmark_Parser_Request_Body_File

Function Benchmark_Parser_Request_Body_File

client/hooks_test.go:759–791  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

757}
758
759func 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
793func newBenchmarkRequest(formValues map[string]string, fileContents [][]byte) *Request {
794 req := &Request{

Callers

nothing calls this directly

Calls 4

newBenchmarkRequestFunction · 0.85
parserRequestBodyFileFunction · 0.85
releaseBenchmarkRequestFunction · 0.85
FatalfMethod · 0.65

Tested by

no test coverage detected