File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -1102,6 +1102,50 @@ func Benchmark_Router_Next_Default_Parallel(b *testing.B) {
1102
1102
})
1103
1103
}
1104
1104
1105
+ // go test -v ./... -run=^$ -bench=Benchmark_Router_Next_Default_Immutable -benchmem -count=4
1106
+ func Benchmark_Router_Next_Default_Immutable (b * testing.B ) {
1107
+ app := New (Config {Immutable : true })
1108
+ app .Get ("/" , func (_ Ctx ) error {
1109
+ return nil
1110
+ })
1111
+
1112
+ h := app .Handler ()
1113
+
1114
+ fctx := & fasthttp.RequestCtx {}
1115
+ fctx .Request .Header .SetMethod (MethodGet )
1116
+ fctx .Request .SetRequestURI ("/" )
1117
+
1118
+ b .ReportAllocs ()
1119
+ b .ResetTimer ()
1120
+
1121
+ for n := 0 ; n < b .N ; n ++ {
1122
+ h (fctx )
1123
+ }
1124
+ }
1125
+
1126
+ // go test -benchmem -run=^$ -bench ^Benchmark_Router_Next_Default_Parallel_Immutable$ github.com/gofiber/fiber/v3 -count=1
1127
+ func Benchmark_Router_Next_Default_Parallel_Immutable (b * testing.B ) {
1128
+ app := New (Config {Immutable : true })
1129
+ app .Get ("/" , func (_ Ctx ) error {
1130
+ return nil
1131
+ })
1132
+
1133
+ h := app .Handler ()
1134
+
1135
+ b .ReportAllocs ()
1136
+ b .ResetTimer ()
1137
+
1138
+ b .RunParallel (func (pb * testing.PB ) {
1139
+ fctx := & fasthttp.RequestCtx {}
1140
+ fctx .Request .Header .SetMethod (MethodGet )
1141
+ fctx .Request .SetRequestURI ("/" )
1142
+
1143
+ for pb .Next () {
1144
+ h (fctx )
1145
+ }
1146
+ })
1147
+ }
1148
+
1105
1149
// go test -v ./... -run=^$ -bench=Benchmark_Route_Match -benchmem -count=4
1106
1150
func Benchmark_Route_Match (b * testing.B ) {
1107
1151
var match bool
You can’t perform that action at this time.
0 commit comments