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

Function BenchmarkState_MustGet

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

Source from the content-addressed store, hash-verified

889}
890
891func BenchmarkState_MustGet(b *testing.B) {
892 b.ReportAllocs()
893
894 st := newState()
895 n := 1000
896 // prepopulate the state
897 for i := range n {
898 key := "key" + strconv.Itoa(i)
899 st.Set(key, i)
900 }
901
902 i := 0
903 for b.Loop() {
904 i++
905 key := "key" + strconv.Itoa(i%n)
906 st.MustGet(key)
907 }
908}
909
910func BenchmarkState_GetStateGeneric(b *testing.B) {
911 b.ReportAllocs()

Callers

nothing calls this directly

Calls 3

newStateFunction · 0.85
MustGetMethod · 0.80
SetMethod · 0.65

Tested by

no test coverage detected