Home / Function/ Benchmark_GenericParseTypeFloats() — fiber Function Reference

Benchmark_GenericParseTypeFloats() — fiber Function Reference

Architecture documentation for the Benchmark_GenericParseTypeFloats() function in helpers_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  617ee278_ac82_0602_e0ca_2a95e2983317["Benchmark_GenericParseTypeFloats()"]
  c82e3595_b1b8_f596_c097_f26fa40159d1["helpers_test.go"]
  617ee278_ac82_0602_e0ca_2a95e2983317 -->|defined in| c82e3595_b1b8_f596_c097_f26fa40159d1
  style 617ee278_ac82_0602_e0ca_2a95e2983317 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

helpers_test.go lines 1359–1414

func Benchmark_GenericParseTypeFloats(b *testing.B) {
	b.Skip("Skipped: too fast to compare reliably (results in sub-ns range are unstable)")
	floats := []struct {
		str   string
		value float64
	}{
		{
			value: 3.1415,
			str:   "3.1415",
		},
		{
			value: 1.234,
			str:   "1.234",
		},
		{
			value: 2,
			str:   "2",
		},
		{
			value: 3,
			str:   "3",
		},
	}

	for _, test := range floats {
		b.Run("benchmark_genericParseTypeFloat32s", func(t *testing.B) {
			var v float32
			var err error
			b.ReportAllocs()
			b.ResetTimer()
			b.RunParallel(func(pb *testing.PB) {
				for pb.Next() {
					v, err = genericParseType[float32](test.str)
				}
			})
			require.NoError(t, err)
			require.InEpsilon(t, float32(test.value), v, epsilon)
		})
	}

	for _, test := range floats {
		b.Run("benchmark_genericParseTypeFloat64s", func(t *testing.B) {
			var v float64
			var err error
			b.ReportAllocs()
			b.ResetTimer()
			b.RunParallel(func(pb *testing.PB) {
				for pb.Next() {
					v, err = genericParseType[float64](test.str)
				}
			})
			require.NoError(t, err)
			require.InEpsilon(t, test.value, v, epsilon)
		})
	}
}

Domain

Subdomains

Defined In

Frequently Asked Questions

What does Benchmark_GenericParseTypeFloats() do?
Benchmark_GenericParseTypeFloats() is a function in the fiber codebase, defined in helpers_test.go.
Where is Benchmark_GenericParseTypeFloats() defined?
Benchmark_GenericParseTypeFloats() is defined in helpers_test.go at line 1359.

Analyze Your Own Codebase

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

Try Supermodel Free