MCPcopy
hub / github.com/danielgtaylor/huma / BenchmarkPathBuffer

Function BenchmarkPathBuffer

bench_test.go:46–82  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

44}
45
46func BenchmarkPathBuffer(b *testing.B) {
47 pb := huma.NewPathBuffer(make([]byte, 0, 128), 0)
48
49 b.Run("Push", func(b *testing.B) {
50 b.ReportAllocs()
51 for i := 0; i < b.N; i++ {
52 pb.Reset()
53 pb.Push("users")
54 pb.Push("profile")
55 pb.Push("settings")
56 pb.Push("theme")
57 }
58 })
59
60 b.Run("PushIndex", func(b *testing.B) {
61 b.ReportAllocs()
62 for i := 0; i < b.N; i++ {
63 pb.Reset()
64 pb.PushIndex(0)
65 pb.PushIndex(10)
66 pb.PushIndex(100)
67 pb.PushIndex(1000)
68 }
69 })
70
71 b.Run("Mixed", func(b *testing.B) {
72 b.ReportAllocs()
73 for i := 0; i < b.N; i++ {
74 pb.Reset()
75 pb.Push("users")
76 pb.PushIndex(5)
77 pb.Push("comments")
78 pb.PushIndex(42)
79 pb.Push("text")
80 }
81 })
82}
83
84func BenchmarkSchemaGeneration(b *testing.B) {
85 t := reflect.TypeFor[BenchComplex]()

Callers

nothing calls this directly

Calls 4

ResetMethod · 0.95
PushMethod · 0.95
PushIndexMethod · 0.95
RunMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…