Home / Function/ Benchmark_SetValWithStruct() — fiber Function Reference

Benchmark_SetValWithStruct() — fiber Function Reference

Architecture documentation for the Benchmark_SetValWithStruct() function in request_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  c2e1cafe_dc4d_1018_55a5_3c09791cd7ac["Benchmark_SetValWithStruct()"]
  3cffa885_3458_eedf_a1f5_10f9dd0f3622["request_test.go"]
  c2e1cafe_dc4d_1018_55a5_3c09791cd7ac -->|defined in| 3cffa885_3458_eedf_a1f5_10f9dd0f3622
  style c2e1cafe_dc4d_1018_55a5_3c09791cd7ac fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

client/request_test.go lines 1743–1903

func Benchmark_SetValWithStruct(b *testing.B) {
	// test SetValWithStruct via QueryParam struct.
	type args struct {
		TString   string
		TSlice    []string
		TIntSlice []int `param:"int_slice"`
		unexport  int
		TInt      int
		TUint     uint
		TFloat    float64
		TComplex  complex128
		TBool     bool
	}

	b.Run("the struct should be applied", func(b *testing.B) {
		p := &QueryParam{
			Args: fasthttp.AcquireArgs(),
		}

		b.ReportAllocs()

		for b.Loop() {
			SetValWithStruct(p, "param", args{
				unexport:  5,
				TInt:      5,
				TUint:     5,
				TString:   "string",
				TFloat:    3.1,
				TComplex:  3 + 4i,
				TBool:     false,
				TSlice:    []string{"foo", "bar"},
				TIntSlice: []int{0, 1, 2},
			})
		}

		require.Empty(b, string(p.Peek("unexport")))
		require.Equal(b, []byte("5"), p.Peek("TInt"))
		require.Equal(b, []byte("5"), p.Peek("TUint"))
		require.Equal(b, []byte("string"), p.Peek("TString"))
		require.Equal(b, []byte("3.1"), p.Peek("TFloat"))
		require.Equal(b, []byte("(3+4i)"), p.Peek("TComplex"))
		require.Equal(b, []byte("false"), p.Peek("TBool"))
		require.True(b, func() bool {
			for _, v := range p.PeekMulti("TSlice") {
				if string(v) == "foo" {
					return true
				}
			}
			return false
		}())

		require.True(b, func() bool {
			for _, v := range p.PeekMulti("TSlice") {
				if string(v) == "bar" {
					return true
				}
			}
			return false
		}())

		require.True(b, func() bool {
			for _, v := range p.PeekMulti("int_slice") {
				if string(v) == "0" {
					return true
				}
			}
			return false
		}())

		require.True(b, func() bool {
			for _, v := range p.PeekMulti("int_slice") {
				if string(v) == "1" {
					return true
				}
			}
			return false
		}())

		require.True(b, func() bool {
			for _, v := range p.PeekMulti("int_slice") {
				if string(v) == "2" {

Domain

Subdomains

Frequently Asked Questions

What does Benchmark_SetValWithStruct() do?
Benchmark_SetValWithStruct() is a function in the fiber codebase, defined in client/request_test.go.
Where is Benchmark_SetValWithStruct() defined?
Benchmark_SetValWithStruct() is defined in client/request_test.go at line 1743.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free