-
Notifications
You must be signed in to change notification settings - Fork 238
/
static_test.go
429 lines (416 loc) · 12.3 KB
/
static_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
// Copyright 2013 Julien Schmidt. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file.
package main
import (
"net/http"
"testing"
)
var staticRoutes = []route{
{"GET", "/"},
{"GET", "/cmd.html"},
{"GET", "/code.html"},
{"GET", "/contrib.html"},
{"GET", "/contribute.html"},
{"GET", "/debugging_with_gdb.html"},
{"GET", "/docs.html"},
{"GET", "/effective_go.html"},
{"GET", "/files.log"},
{"GET", "/gccgo_contribute.html"},
{"GET", "/gccgo_install.html"},
{"GET", "/go-logo-black.png"},
{"GET", "/go-logo-blue.png"},
{"GET", "/go-logo-white.png"},
{"GET", "/go1.1.html"},
{"GET", "/go1.2.html"},
{"GET", "/go1.html"},
{"GET", "/go1compat.html"},
{"GET", "/go_faq.html"},
{"GET", "/go_mem.html"},
{"GET", "/go_spec.html"},
{"GET", "/help.html"},
{"GET", "/ie.css"},
{"GET", "/install-source.html"},
{"GET", "/install.html"},
{"GET", "/logo-153x55.png"},
{"GET", "/Makefile"},
{"GET", "/root.html"},
{"GET", "/share.png"},
{"GET", "/sieve.gif"},
{"GET", "/tos.html"},
{"GET", "/articles"},
{"GET", "/articles/go_command.html"},
{"GET", "/articles/index.html"},
{"GET", "/articles/wiki"},
{"GET", "/articles/wiki/edit.html"},
{"GET", "/articles/wiki/final-noclosure.go"},
{"GET", "/articles/wiki/final-noerror.go"},
{"GET", "/articles/wiki/final-parsetemplate.go"},
{"GET", "/articles/wiki/final-template.go"},
{"GET", "/articles/wiki/final.go"},
{"GET", "/articles/wiki/get.go"},
{"GET", "/articles/wiki/http-sample.go"},
{"GET", "/articles/wiki/index.html"},
{"GET", "/articles/wiki/Makefile"},
{"GET", "/articles/wiki/notemplate.go"},
{"GET", "/articles/wiki/part1-noerror.go"},
{"GET", "/articles/wiki/part1.go"},
{"GET", "/articles/wiki/part2.go"},
{"GET", "/articles/wiki/part3-errorhandling.go"},
{"GET", "/articles/wiki/part3.go"},
{"GET", "/articles/wiki/test.bash"},
{"GET", "/articles/wiki/test_edit.good"},
{"GET", "/articles/wiki/test_Test.txt.good"},
{"GET", "/articles/wiki/test_view.good"},
{"GET", "/articles/wiki/view.html"},
{"GET", "/codewalk"},
{"GET", "/codewalk/codewalk.css"},
{"GET", "/codewalk/codewalk.js"},
{"GET", "/codewalk/codewalk.xml"},
{"GET", "/codewalk/functions.xml"},
{"GET", "/codewalk/markov.go"},
{"GET", "/codewalk/markov.xml"},
{"GET", "/codewalk/pig.go"},
{"GET", "/codewalk/popout.png"},
{"GET", "/codewalk/run"},
{"GET", "/codewalk/sharemem.xml"},
{"GET", "/codewalk/urlpoll.go"},
{"GET", "/devel"},
{"GET", "/devel/release.html"},
{"GET", "/devel/weekly.html"},
{"GET", "/gopher"},
{"GET", "/gopher/appenginegopher.jpg"},
{"GET", "/gopher/appenginegophercolor.jpg"},
{"GET", "/gopher/appenginelogo.gif"},
{"GET", "/gopher/bumper.png"},
{"GET", "/gopher/bumper192x108.png"},
{"GET", "/gopher/bumper320x180.png"},
{"GET", "/gopher/bumper480x270.png"},
{"GET", "/gopher/bumper640x360.png"},
{"GET", "/gopher/doc.png"},
{"GET", "/gopher/frontpage.png"},
{"GET", "/gopher/gopherbw.png"},
{"GET", "/gopher/gophercolor.png"},
{"GET", "/gopher/gophercolor16x16.png"},
{"GET", "/gopher/help.png"},
{"GET", "/gopher/pkg.png"},
{"GET", "/gopher/project.png"},
{"GET", "/gopher/ref.png"},
{"GET", "/gopher/run.png"},
{"GET", "/gopher/talks.png"},
{"GET", "/gopher/pencil"},
{"GET", "/gopher/pencil/gopherhat.jpg"},
{"GET", "/gopher/pencil/gopherhelmet.jpg"},
{"GET", "/gopher/pencil/gophermega.jpg"},
{"GET", "/gopher/pencil/gopherrunning.jpg"},
{"GET", "/gopher/pencil/gopherswim.jpg"},
{"GET", "/gopher/pencil/gopherswrench.jpg"},
{"GET", "/play"},
{"GET", "/play/fib.go"},
{"GET", "/play/hello.go"},
{"GET", "/play/life.go"},
{"GET", "/play/peano.go"},
{"GET", "/play/pi.go"},
{"GET", "/play/sieve.go"},
{"GET", "/play/solitaire.go"},
{"GET", "/play/tree.go"},
{"GET", "/progs"},
{"GET", "/progs/cgo1.go"},
{"GET", "/progs/cgo2.go"},
{"GET", "/progs/cgo3.go"},
{"GET", "/progs/cgo4.go"},
{"GET", "/progs/defer.go"},
{"GET", "/progs/defer.out"},
{"GET", "/progs/defer2.go"},
{"GET", "/progs/defer2.out"},
{"GET", "/progs/eff_bytesize.go"},
{"GET", "/progs/eff_bytesize.out"},
{"GET", "/progs/eff_qr.go"},
{"GET", "/progs/eff_sequence.go"},
{"GET", "/progs/eff_sequence.out"},
{"GET", "/progs/eff_unused1.go"},
{"GET", "/progs/eff_unused2.go"},
{"GET", "/progs/error.go"},
{"GET", "/progs/error2.go"},
{"GET", "/progs/error3.go"},
{"GET", "/progs/error4.go"},
{"GET", "/progs/go1.go"},
{"GET", "/progs/gobs1.go"},
{"GET", "/progs/gobs2.go"},
{"GET", "/progs/image_draw.go"},
{"GET", "/progs/image_package1.go"},
{"GET", "/progs/image_package1.out"},
{"GET", "/progs/image_package2.go"},
{"GET", "/progs/image_package2.out"},
{"GET", "/progs/image_package3.go"},
{"GET", "/progs/image_package3.out"},
{"GET", "/progs/image_package4.go"},
{"GET", "/progs/image_package4.out"},
{"GET", "/progs/image_package5.go"},
{"GET", "/progs/image_package5.out"},
{"GET", "/progs/image_package6.go"},
{"GET", "/progs/image_package6.out"},
{"GET", "/progs/interface.go"},
{"GET", "/progs/interface2.go"},
{"GET", "/progs/interface2.out"},
{"GET", "/progs/json1.go"},
{"GET", "/progs/json2.go"},
{"GET", "/progs/json2.out"},
{"GET", "/progs/json3.go"},
{"GET", "/progs/json4.go"},
{"GET", "/progs/json5.go"},
{"GET", "/progs/run"},
{"GET", "/progs/slices.go"},
{"GET", "/progs/timeout1.go"},
{"GET", "/progs/timeout2.go"},
{"GET", "/progs/update.bash"},
}
var (
staticHttpServeMux http.Handler
staticAce http.Handler
staticAero http.Handler
staticBear http.Handler
staticBeego http.Handler
staticBone http.Handler
staticChi http.Handler
staticCloudyKitRouter http.Handler
staticDenco http.Handler
staticEcho http.Handler
staticGin http.Handler
staticGocraftWeb http.Handler
staticGoji http.Handler
staticGojiv2 http.Handler
staticGoJsonRest http.Handler
staticGoRestful http.Handler
staticGorillaMux http.Handler
staticGowwwRouter http.Handler
staticHttpRouter http.Handler
staticHttpTreeMux http.Handler
staticKocha http.Handler
staticLARS http.Handler
staticMacaron http.Handler
staticMartini http.Handler
staticPat http.Handler
staticPossum http.Handler
staticR2router http.Handler
// staticRevel http.Handler
staticRivet http.Handler
staticTango http.Handler
staticTigerTonic http.Handler
staticTraffic http.Handler
staticVulcan http.Handler
// staticZeus http.Handler
)
func init() {
println("#Static Routes:", len(staticRoutes))
calcMem("HttpServeMux", func() {
serveMux := http.NewServeMux()
for _, route := range staticRoutes {
serveMux.HandleFunc(route.path, httpHandlerFunc)
}
staticHttpServeMux = serveMux
})
calcMem("Ace", func() {
staticAce = loadAce(staticRoutes)
})
calcMem("Aero", func() {
staticAero = loadAero(staticRoutes)
})
calcMem("Bear", func() {
staticBear = loadBear(staticRoutes)
})
calcMem("Beego", func() {
staticBeego = loadBeego(staticRoutes)
})
calcMem("Bone", func() {
staticBone = loadBone(staticRoutes)
})
calcMem("Chi", func() {
staticChi = loadChi(staticRoutes)
})
calcMem("CloudyKitRouter", func() {
staticCloudyKitRouter = loadCloudyKitRouter(staticRoutes)
})
calcMem("Denco", func() {
staticDenco = loadDenco(staticRoutes)
})
calcMem("Echo", func() {
staticEcho = loadEcho(staticRoutes)
})
calcMem("Gin", func() {
staticGin = loadGin(staticRoutes)
})
calcMem("GocraftWeb", func() {
staticGocraftWeb = loadGocraftWeb(staticRoutes)
})
calcMem("Goji", func() {
staticGoji = loadGoji(staticRoutes)
})
calcMem("Gojiv2", func() {
staticGojiv2 = loadGojiv2(staticRoutes)
})
calcMem("GoJsonRest", func() {
staticGoJsonRest = loadGoJsonRest(staticRoutes)
})
calcMem("GoRestful", func() {
staticGoRestful = loadGoRestful(staticRoutes)
})
calcMem("GorillaMux", func() {
staticGorillaMux = loadGorillaMux(staticRoutes)
})
calcMem("GowwwRouter", func() {
staticGowwwRouter = loadGowwwRouter(staticRoutes)
})
calcMem("HttpRouter", func() {
staticHttpRouter = loadHttpRouter(staticRoutes)
})
calcMem("HttpTreeMux", func() {
staticHttpTreeMux = loadHttpTreeMux(staticRoutes)
})
calcMem("Kocha", func() {
staticKocha = loadKocha(staticRoutes)
})
calcMem("LARS", func() {
staticLARS = loadLARS(staticRoutes)
})
calcMem("Macaron", func() {
staticMacaron = loadMacaron(staticRoutes)
})
calcMem("Martini", func() {
staticMartini = loadMartini(staticRoutes)
})
calcMem("Pat", func() {
staticPat = loadPat(staticRoutes)
})
calcMem("Possum", func() {
staticPossum = loadPossum(staticRoutes)
})
calcMem("R2router", func() {
staticR2router = loadR2router(staticRoutes)
})
// calcMem("Revel", func() {
// staticRevel = loadRevel(staticRoutes)
// })
calcMem("Rivet", func() {
staticRivet = loadRivet(staticRoutes)
})
calcMem("Tango", func() {
staticTango = loadTango(staticRoutes)
})
calcMem("TigerTonic", func() {
staticTigerTonic = loadTigerTonic(staticRoutes)
})
calcMem("Traffic", func() {
staticTraffic = loadTraffic(staticRoutes)
})
calcMem("Vulcan", func() {
staticVulcan = loadVulcan(staticRoutes)
})
// calcMem("Zeus", func() {
// staticZeus = loadZeus(staticRoutes)
// })
println()
}
// All routes
func BenchmarkAce_StaticAll(b *testing.B) {
benchRoutes(b, staticAce, staticRoutes)
}
func BenchmarkAero_StaticAll(b *testing.B) {
benchRoutes(b, staticAero, staticRoutes)
}
func BenchmarkHttpServeMux_StaticAll(b *testing.B) {
benchRoutes(b, staticHttpServeMux, staticRoutes)
}
func BenchmarkBeego_StaticAll(b *testing.B) {
benchRoutes(b, staticBeego, staticRoutes)
}
func BenchmarkBear_StaticAll(b *testing.B) {
benchRoutes(b, staticBear, staticRoutes)
}
func BenchmarkBone_StaticAll(b *testing.B) {
benchRoutes(b, staticBone, staticRoutes)
}
func BenchmarkChi_StaticAll(b *testing.B) {
benchRoutes(b, staticChi, staticRoutes)
}
func BenchmarkCloudyKitRouter_StaticAll(b *testing.B) {
benchRoutes(b, staticCloudyKitRouter, staticRoutes)
}
func BenchmarkDenco_StaticAll(b *testing.B) {
benchRoutes(b, staticDenco, staticRoutes)
}
func BenchmarkEcho_StaticAll(b *testing.B) {
benchRoutes(b, staticEcho, staticRoutes)
}
func BenchmarkGin_StaticAll(b *testing.B) {
benchRoutes(b, staticGin, staticRoutes)
}
func BenchmarkGocraftWeb_StaticAll(b *testing.B) {
benchRoutes(b, staticGocraftWeb, staticRoutes)
}
func BenchmarkGoji_StaticAll(b *testing.B) {
benchRoutes(b, staticGoji, staticRoutes)
}
func BenchmarkGojiv2_StaticAll(b *testing.B) {
benchRoutes(b, staticGojiv2, staticRoutes)
}
func BenchmarkGoJsonRest_StaticAll(b *testing.B) {
benchRoutes(b, staticGoJsonRest, staticRoutes)
}
func BenchmarkGoRestful_StaticAll(b *testing.B) {
benchRoutes(b, staticGoRestful, staticRoutes)
}
func BenchmarkGorillaMux_StaticAll(b *testing.B) {
benchRoutes(b, staticGorillaMux, staticRoutes)
}
func BenchmarkGowwwRouter_StaticAll(b *testing.B) {
benchRoutes(b, staticGowwwRouter, staticRoutes)
}
func BenchmarkHttpRouter_StaticAll(b *testing.B) {
benchRoutes(b, staticHttpRouter, staticRoutes)
}
func BenchmarkHttpTreeMux_StaticAll(b *testing.B) {
benchRoutes(b, staticHttpRouter, staticRoutes)
}
func BenchmarkKocha_StaticAll(b *testing.B) {
benchRoutes(b, staticKocha, staticRoutes)
}
func BenchmarkLARS_StaticAll(b *testing.B) {
benchRoutes(b, staticLARS, staticRoutes)
}
func BenchmarkMacaron_StaticAll(b *testing.B) {
benchRoutes(b, staticMacaron, staticRoutes)
}
func BenchmarkMartini_StaticAll(b *testing.B) {
benchRoutes(b, staticMartini, staticRoutes)
}
func BenchmarkPat_StaticAll(b *testing.B) {
benchRoutes(b, staticPat, staticRoutes)
}
func BenchmarkPossum_StaticAll(b *testing.B) {
benchRoutes(b, staticPossum, staticRoutes)
}
func BenchmarkR2router_StaticAll(b *testing.B) {
benchRoutes(b, staticR2router, staticRoutes)
}
// func BenchmarkRevel_StaticAll(b *testing.B) {
// benchRoutes(b, staticRevel, staticRoutes)
// }
func BenchmarkRivet_StaticAll(b *testing.B) {
benchRoutes(b, staticRivet, staticRoutes)
}
func BenchmarkTango_StaticAll(b *testing.B) {
benchRoutes(b, staticTango, staticRoutes)
}
func BenchmarkTigerTonic_StaticAll(b *testing.B) {
benchRoutes(b, staticTigerTonic, staticRoutes)
}
func BenchmarkTraffic_StaticAll(b *testing.B) {
benchRoutes(b, staticTraffic, staticRoutes)
}
func BenchmarkVulcan_StaticAll(b *testing.B) {
benchRoutes(b, staticVulcan, staticRoutes)
}
// func BenchmarkZeus_StaticAll(b *testing.B) {
// benchRoutes(b, staticZeus, staticRoutes)
// }