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

Function BenchmarkState_GetString

state_test.go:815–832  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

813}
814
815func BenchmarkState_GetString(b *testing.B) {
816 b.ReportAllocs()
817
818 st := newState()
819 n := 1000
820 // prepopulate the state
821 for i := range n {
822 key := "key" + strconv.Itoa(i)
823 st.Set(key, strconv.Itoa(i))
824 }
825
826 i := 0
827 for b.Loop() {
828 i++
829 key := "key" + strconv.Itoa(i%n)
830 st.GetString(key)
831 }
832}
833
834func BenchmarkState_GetInt(b *testing.B) {
835 b.ReportAllocs()

Callers

nothing calls this directly

Calls 3

newStateFunction · 0.85
SetMethod · 0.65
GetStringMethod · 0.45

Tested by

no test coverage detected