-
Notifications
You must be signed in to change notification settings - Fork 0
/
routerbench_test.go
614 lines (573 loc) · 21.2 KB
/
routerbench_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
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
package jago
/*
Array
cpu: Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
BenchmarkJagoStatic-8 5368 218774 ns/op 48526 B/op 1143 allocs/op
BenchmarkJagoGitHubAPI-8 2821 414983 ns/op 133150 B/op 1794 allocs/op
BenchmarkJagoGplusAPI-8 71121 18115 ns/op 7635 B/op 108 allocs/op
BenchmarkJagoParseAPI-8 42877 30929 ns/op 13924 B/op 218 allocs/op
One Level Tree
cpu: Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
BenchmarkJagoStatic-8 6501 165238 ns/op 47945 B/op 1114 allocs/op
BenchmarkJagoGitHubAPI-8 3331 324038 ns/op 132919 B/op 1794 allocs/op
BenchmarkJagoGplusAPI-8 115554 10472 ns/op 7648 B/op 108 allocs/op
BenchmarkJagoParseAPI-8 46396 32629 ns/op 13909 B/op 218 allocs/op
Tree
cpu: Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
BenchmarkJagoStatic-8 12871 92013 ns/op 47775 B/op 1094 allocs/op
BenchmarkJagoGitHubAPI-8 3350 299073 ns/op 175128 B/op 2703 allocs/op
BenchmarkJagoGplusAPI-8 75843 18941 ns/op 9767 B/op 168 allocs/op
BenchmarkJagoParseAPI-8 37186 30077 ns/op 17602 B/op 320 allocs/op
BeegoMux
cpu: Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
BenchmarkMuxStatic-8 35121 35218 ns/op 15182 B/op 314 allocs/op
BenchmarkMuxGitHubAPI-8 10000 104671 ns/op 123348 B/op 1074 allocs/op
BenchmarkMuxGplusAPI-8 215536 7596 ns/op 8286 B/op 70 allocs/op
BenchmarkMuxParseAPI-8 104617 9879 ns/op 12771 B/op 116 allocs/op
Eho
cpu: Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
BenchmarkEchoStatic-8 33364 43531 ns/op 2264 B/op 157 allocs/op
BenchmarkEchoGitHubAPI-8 19813 61690 ns/op 2477 B/op 203 allocs/op
BenchmarkEchoGplusAPI-8 413618 3039 ns/op 185 B/op 13 allocs/op
BenchmarkEchoParseAPI-8 259466 4991 ns/op 337 B/op 26 allocs/op
Gin
BenchmarkGinStatic-8 25494 46172 ns/op 11967 B/op 314 allocs/op
BenchmarkGinGitHubAPI-8 18987 61844 ns/op 15508 B/op 406 allocs/op
BenchmarkGinGplusAPI-8 333837 3490 ns/op 1036 B/op 26 allocs/op
BenchmarkGinParseAPI-8 180140 6541 ns/op 2058 B/op 52 allocs/op
*/
import (
"net/http"
"net/http/httptest"
"testing"
)
type (
Route struct {
Method string
Path string
}
)
var (
static = []*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"},
}
githubAPI = []*Route{
// OAuth Authorizations
{"GET", "/authorizations"},
{"GET", "/authorizations/:id"},
{"POST", "/authorizations"},
//{"PUT", "/authorizations/clients/:client_id"},
//{"PATCH", "/authorizations/:id"},
{"DELETE", "/authorizations/:id"},
{"GET", "/applications/:client_id/tokens/:access_token"},
{"DELETE", "/applications/:client_id/tokens"},
{"DELETE", "/applications/:client_id/tokens/:access_token"},
// Activity
{"GET", "/events"},
{"GET", "/repos/:owner/:repo/events"},
{"GET", "/networks/:owner/:repo/events"},
{"GET", "/orgs/:org/events"},
{"GET", "/users/:user/received_events"},
{"GET", "/users/:user/received_events/public"},
{"GET", "/users/:user/events"},
{"GET", "/users/:user/events/public"},
{"GET", "/users/:user/events/orgs/:org"},
{"GET", "/feeds"},
{"GET", "/notifications"},
{"GET", "/repos/:owner/:repo/notifications"},
{"PUT", "/notifications"},
{"PUT", "/repos/:owner/:repo/notifications"},
{"GET", "/notifications/threads/:id"},
//{"PATCH", "/notifications/threads/:id"},
{"GET", "/notifications/threads/:id/subscription"},
{"PUT", "/notifications/threads/:id/subscription"},
{"DELETE", "/notifications/threads/:id/subscription"},
{"GET", "/repos/:owner/:repo/stargazers"},
{"GET", "/users/:user/starred"},
{"GET", "/user/starred"},
{"GET", "/user/starred/:owner/:repo"},
{"PUT", "/user/starred/:owner/:repo"},
{"DELETE", "/user/starred/:owner/:repo"},
{"GET", "/repos/:owner/:repo/subscribers"},
{"GET", "/users/:user/subscriptions"},
{"GET", "/user/subscriptions"},
{"GET", "/repos/:owner/:repo/subscription"},
{"PUT", "/repos/:owner/:repo/subscription"},
{"DELETE", "/repos/:owner/:repo/subscription"},
{"GET", "/user/subscriptions/:owner/:repo"},
{"PUT", "/user/subscriptions/:owner/:repo"},
{"DELETE", "/user/subscriptions/:owner/:repo"},
// Gists
{"GET", "/users/:user/gists"},
{"GET", "/gists"},
//{"GET", "/gists/public"},
//{"GET", "/gists/starred"},
{"GET", "/gists/:id"},
{"POST", "/gists"},
//{"PATCH", "/gists/:id"},
{"PUT", "/gists/:id/star"},
{"DELETE", "/gists/:id/star"},
{"GET", "/gists/:id/star"},
{"POST", "/gists/:id/forks"},
{"DELETE", "/gists/:id"},
// Git Data
{"GET", "/repos/:owner/:repo/git/blobs/:sha"},
{"POST", "/repos/:owner/:repo/git/blobs"},
{"GET", "/repos/:owner/:repo/git/commits/:sha"},
{"POST", "/repos/:owner/:repo/git/commits"},
//{"GET", "/repos/:owner/:repo/git/refs/*ref"},
{"GET", "/repos/:owner/:repo/git/refs"},
{"POST", "/repos/:owner/:repo/git/refs"},
//{"PATCH", "/repos/:owner/:repo/git/refs/*ref"},
//{"DELETE", "/repos/:owner/:repo/git/refs/*ref"},
{"GET", "/repos/:owner/:repo/git/tags/:sha"},
{"POST", "/repos/:owner/:repo/git/tags"},
{"GET", "/repos/:owner/:repo/git/trees/:sha"},
{"POST", "/repos/:owner/:repo/git/trees"},
// Issues
{"GET", "/issues"},
{"GET", "/user/issues"},
{"GET", "/orgs/:org/issues"},
{"GET", "/repos/:owner/:repo/issues"},
{"GET", "/repos/:owner/:repo/issues/:number"},
{"POST", "/repos/:owner/:repo/issues"},
//{"PATCH", "/repos/:owner/:repo/issues/:number"},
{"GET", "/repos/:owner/:repo/assignees"},
{"GET", "/repos/:owner/:repo/assignees/:assignee"},
{"GET", "/repos/:owner/:repo/issues/:number/comments"},
//{"GET", "/repos/:owner/:repo/issues/comments"},
//{"GET", "/repos/:owner/:repo/issues/comments/:id"},
{"POST", "/repos/:owner/:repo/issues/:number/comments"},
//{"PATCH", "/repos/:owner/:repo/issues/comments/:id"},
//{"DELETE", "/repos/:owner/:repo/issues/comments/:id"},
{"GET", "/repos/:owner/:repo/issues/:number/events"},
//{"GET", "/repos/:owner/:repo/issues/events"},
//{"GET", "/repos/:owner/:repo/issues/events/:id"},
{"GET", "/repos/:owner/:repo/labels"},
{"GET", "/repos/:owner/:repo/labels/:name"},
{"POST", "/repos/:owner/:repo/labels"},
//{"PATCH", "/repos/:owner/:repo/labels/:name"},
{"DELETE", "/repos/:owner/:repo/labels/:name"},
{"GET", "/repos/:owner/:repo/issues/:number/labels"},
{"POST", "/repos/:owner/:repo/issues/:number/labels"},
{"DELETE", "/repos/:owner/:repo/issues/:number/labels/:name"},
{"PUT", "/repos/:owner/:repo/issues/:number/labels"},
{"DELETE", "/repos/:owner/:repo/issues/:number/labels"},
{"GET", "/repos/:owner/:repo/milestones/:number/labels"},
{"GET", "/repos/:owner/:repo/milestones"},
{"GET", "/repos/:owner/:repo/milestones/:number"},
{"POST", "/repos/:owner/:repo/milestones"},
//{"PATCH", "/repos/:owner/:repo/milestones/:number"},
{"DELETE", "/repos/:owner/:repo/milestones/:number"},
// Miscellaneous
{"GET", "/emojis"},
{"GET", "/gitignore/templates"},
{"GET", "/gitignore/templates/:name"},
{"POST", "/markdown"},
{"POST", "/markdown/raw"},
{"GET", "/meta"},
{"GET", "/rate_limit"},
// Organizations
{"GET", "/users/:user/orgs"},
{"GET", "/user/orgs"},
{"GET", "/orgs/:org"},
//{"PATCH", "/orgs/:org"},
{"GET", "/orgs/:org/members"},
{"GET", "/orgs/:org/members/:user"},
{"DELETE", "/orgs/:org/members/:user"},
{"GET", "/orgs/:org/public_members"},
{"GET", "/orgs/:org/public_members/:user"},
{"PUT", "/orgs/:org/public_members/:user"},
{"DELETE", "/orgs/:org/public_members/:user"},
{"GET", "/orgs/:org/teams"},
{"GET", "/teams/:id"},
{"POST", "/orgs/:org/teams"},
//{"PATCH", "/teams/:id"},
{"DELETE", "/teams/:id"},
{"GET", "/teams/:id/members"},
{"GET", "/teams/:id/members/:user"},
{"PUT", "/teams/:id/members/:user"},
{"DELETE", "/teams/:id/members/:user"},
{"GET", "/teams/:id/repos"},
{"GET", "/teams/:id/repos/:owner/:repo"},
{"PUT", "/teams/:id/repos/:owner/:repo"},
{"DELETE", "/teams/:id/repos/:owner/:repo"},
{"GET", "/user/teams"},
// Pull Requests
{"GET", "/repos/:owner/:repo/pulls"},
{"GET", "/repos/:owner/:repo/pulls/:number"},
{"POST", "/repos/:owner/:repo/pulls"},
//{"PATCH", "/repos/:owner/:repo/pulls/:number"},
{"GET", "/repos/:owner/:repo/pulls/:number/commits"},
{"GET", "/repos/:owner/:repo/pulls/:number/files"},
{"GET", "/repos/:owner/:repo/pulls/:number/merge"},
{"PUT", "/repos/:owner/:repo/pulls/:number/merge"},
{"GET", "/repos/:owner/:repo/pulls/:number/comments"},
//{"GET", "/repos/:owner/:repo/pulls/comments"},
//{"GET", "/repos/:owner/:repo/pulls/comments/:number"},
{"PUT", "/repos/:owner/:repo/pulls/:number/comments"},
//{"PATCH", "/repos/:owner/:repo/pulls/comments/:number"},
//{"DELETE", "/repos/:owner/:repo/pulls/comments/:number"},
// Repositories
{"GET", "/user/repos"},
{"GET", "/users/:user/repos"},
{"GET", "/orgs/:org/repos"},
{"GET", "/repositories"},
{"POST", "/user/repos"},
{"POST", "/orgs/:org/repos"},
{"GET", "/repos/:owner/:repo"},
//{"PATCH", "/repos/:owner/:repo"},
{"GET", "/repos/:owner/:repo/contributors"},
{"GET", "/repos/:owner/:repo/languages"},
{"GET", "/repos/:owner/:repo/teams"},
{"GET", "/repos/:owner/:repo/tags"},
{"GET", "/repos/:owner/:repo/branches"},
{"GET", "/repos/:owner/:repo/branches/:branch"},
{"DELETE", "/repos/:owner/:repo"},
{"GET", "/repos/:owner/:repo/collaborators"},
{"GET", "/repos/:owner/:repo/collaborators/:user"},
{"PUT", "/repos/:owner/:repo/collaborators/:user"},
{"DELETE", "/repos/:owner/:repo/collaborators/:user"},
{"GET", "/repos/:owner/:repo/comments"},
{"GET", "/repos/:owner/:repo/commits/:sha/comments"},
{"POST", "/repos/:owner/:repo/commits/:sha/comments"},
{"GET", "/repos/:owner/:repo/comments/:id"},
//{"PATCH", "/repos/:owner/:repo/comments/:id"},
{"DELETE", "/repos/:owner/:repo/comments/:id"},
{"GET", "/repos/:owner/:repo/commits"},
{"GET", "/repos/:owner/:repo/commits/:sha"},
{"GET", "/repos/:owner/:repo/readme"},
//{"GET", "/repos/:owner/:repo/contents/*path"},
//{"PUT", "/repos/:owner/:repo/contents/*path"},
//{"DELETE", "/repos/:owner/:repo/contents/*path"},
//{"GET", "/repos/:owner/:repo/:archive_format/:ref"},
{"GET", "/repos/:owner/:repo/keys"},
{"GET", "/repos/:owner/:repo/keys/:id"},
{"POST", "/repos/:owner/:repo/keys"},
//{"PATCH", "/repos/:owner/:repo/keys/:id"},
{"DELETE", "/repos/:owner/:repo/keys/:id"},
{"GET", "/repos/:owner/:repo/downloads"},
{"GET", "/repos/:owner/:repo/downloads/:id"},
{"DELETE", "/repos/:owner/:repo/downloads/:id"},
{"GET", "/repos/:owner/:repo/forks"},
{"POST", "/repos/:owner/:repo/forks"},
{"GET", "/repos/:owner/:repo/hooks"},
{"GET", "/repos/:owner/:repo/hooks/:id"},
{"POST", "/repos/:owner/:repo/hooks"},
//{"PATCH", "/repos/:owner/:repo/hooks/:id"},
{"POST", "/repos/:owner/:repo/hooks/:id/tests"},
{"DELETE", "/repos/:owner/:repo/hooks/:id"},
{"POST", "/repos/:owner/:repo/merges"},
{"GET", "/repos/:owner/:repo/releases"},
{"GET", "/repos/:owner/:repo/releases/:id"},
{"POST", "/repos/:owner/:repo/releases"},
//{"PATCH", "/repos/:owner/:repo/releases/:id"},
{"DELETE", "/repos/:owner/:repo/releases/:id"},
{"GET", "/repos/:owner/:repo/releases/:id/assets"},
{"GET", "/repos/:owner/:repo/stats/contributors"},
{"GET", "/repos/:owner/:repo/stats/commit_activity"},
{"GET", "/repos/:owner/:repo/stats/code_frequency"},
{"GET", "/repos/:owner/:repo/stats/participation"},
{"GET", "/repos/:owner/:repo/stats/punch_card"},
{"GET", "/repos/:owner/:repo/statuses/:ref"},
{"POST", "/repos/:owner/:repo/statuses/:ref"},
// Search
{"GET", "/search/repositories"},
{"GET", "/search/code"},
{"GET", "/search/issues"},
{"GET", "/search/users"},
{"GET", "/legacy/issues/search/:owner/:repository/:state/:keyword"},
{"GET", "/legacy/repos/search/:keyword"},
{"GET", "/legacy/user/search/:keyword"},
{"GET", "/legacy/user/email/:email"},
// Users
{"GET", "/users/:user"},
{"GET", "/user"},
//{"PATCH", "/user"},
{"GET", "/users"},
{"GET", "/user/emails"},
{"POST", "/user/emails"},
{"DELETE", "/user/emails"},
{"GET", "/users/:user/followers"},
{"GET", "/user/followers"},
{"GET", "/users/:user/following"},
{"GET", "/user/following"},
{"GET", "/user/following/:user"},
{"GET", "/users/:user/following/:target_user"},
{"PUT", "/user/following/:user"},
{"DELETE", "/user/following/:user"},
{"GET", "/users/:user/keys"},
{"GET", "/user/keys"},
{"GET", "/user/keys/:id"},
{"POST", "/user/keys"},
//{"PATCH", "/user/keys/:id"},
{"DELETE", "/user/keys/:id"},
}
gplusAPI = []*Route{
// People
{"GET", "/people/:userId"},
{"GET", "/people"},
{"GET", "/activities/:activityId/people/:collection"},
{"GET", "/people/:userId/people/:collection"},
{"GET", "/people/:userId/openIdConnect"},
// Activities
{"GET", "/people/:userId/activities/:collection"},
{"GET", "/activities/:activityId"},
{"GET", "/activities"},
// Comments
{"GET", "/activities/:activityId/comments"},
{"GET", "/comments/:commentId"},
// Moments
{"POST", "/people/:userId/moments/:collection"},
{"GET", "/people/:userId/moments/:collection"},
{"DELETE", "/moments/:id"},
}
parseAPI = []*Route{
// Objects
{"POST", "/1/classes/:className"},
{"GET", "/1/classes/:className/:objectId"},
{"PUT", "/1/classes/:className/:objectId"},
{"GET", "/1/classes/:className"},
{"DELETE", "/1/classes/:className/:objectId"},
{"GET", "/1/:type/Category/Item"},
// Users
{"POST", "/1/users"},
{"GET", "/1/login"},
{"GET", "/1/users/:objectId"},
{"PUT", "/1/users/:objectId"},
{"GET", "/1/users"},
{"DELETE", "/1/users/:objectId"},
{"POST", "/1/requestPasswordReset"},
// Roles
{"POST", "/1/Roles"},
{"GET", "/1/Roles/:objectId"},
{"PUT", "/1/Roles/:objectId"},
{"GET", "/1/Roles"},
{"DELETE", "/1/Roles/:objectId"},
// Files
{"POST", "/1/files/:fileName"},
// Analytics
{"POST", "/1/events/:eventName"},
// Push Notifications
{"POST", "/1/push"},
// Installations
{"POST", "/1/installations"},
{"GET", "/1/installations/:objectId"},
{"PUT", "/1/installations/:objectId"},
{"GET", "/1/installations"},
{"DELETE", "/1/installations/:objectId"},
// Cloud Functions
{"GET", "/1/functions/*"},
}
)
func benchmarkRoutes(b *testing.B, router http.Handler, routes []*Route) {
b.ReportAllocs()
r := httptest.NewRequest("GET", "/", nil)
u := r.URL
w := httptest.NewRecorder()
for i := 0; i < b.N; i++ {
for _, route := range routes {
r.Method = route.Method
u.Path = route.Path
router.ServeHTTP(w, r)
}
}
}
func loadJagoRoutes(g *Jago, routes []*Route) {
for _, r := range routes {
switch r.Method {
case "GET":
g.Get(r.Path, jagoHandler(r.Method, r.Path))
case "POST":
g.Post(r.Path, jagoHandler(r.Method, r.Path))
case "PATCH":
g.Patch(r.Path, jagoHandler(r.Method, r.Path))
case "PUT":
g.Put(r.Path, jagoHandler(r.Method, r.Path))
case "DELETE":
g.Delete(r.Path, jagoHandler(r.Method, r.Path))
}
}
g.PrintRouter()
}
func jagoHandler(method, path string) HandlerFunc {
return func(c Context) error {
return c.String(http.StatusOK, "OK")
}
}
func BenchmarkJagoStatic(b *testing.B) {
g := New()
loadJagoRoutes(g, static)
benchmarkRoutes(b, g, static)
}
func BenchmarkJagoGitHubAPI(b *testing.B) {
g := New()
loadJagoRoutes(g, githubAPI)
benchmarkRoutes(b, g, githubAPI)
}
func BenchmarkJagoGplusAPI(b *testing.B) {
g := New()
loadJagoRoutes(g, gplusAPI)
benchmarkRoutes(b, g, gplusAPI)
}
func BenchmarkJagoParseAPI(b *testing.B) {
g := New()
loadJagoRoutes(g, parseAPI)
benchmarkRoutes(b, g, parseAPI)
}