| 44 | } |
| 45 | |
| 46 | func 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 | |
| 84 | func BenchmarkSchemaGeneration(b *testing.B) { |
| 85 | t := reflect.TypeFor[BenchComplex]() |