File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,11 @@ func calcMem(name string, load func()) {
45
45
m := new (runtime.MemStats )
46
46
47
47
// before
48
+ // force GC multiple times, since Go is using a generational GC
49
+ // TODO: find a better approach
50
+ runtime .GC ()
51
+ runtime .GC ()
52
+ runtime .GC ()
48
53
runtime .GC ()
49
54
runtime .ReadMemStats (m )
50
55
before := m .HeapAlloc
@@ -53,6 +58,9 @@ func calcMem(name string, load func()) {
53
58
54
59
// after
55
60
runtime .GC ()
61
+ runtime .GC ()
62
+ runtime .GC ()
63
+ runtime .GC ()
56
64
runtime .ReadMemStats (m )
57
65
after := m .HeapAlloc
58
66
println (" " + name + ":" , after - before , "Bytes" )
@@ -220,7 +228,6 @@ func BenchmarkPat_Param(b *testing.B) {
220
228
r , _ := http .NewRequest ("GET" , "/user/gordon" , nil )
221
229
benchRequest (b , router , r )
222
230
}
223
-
224
231
func BenchmarkPossum_Param (b * testing.B ) {
225
232
router := loadPossumSingle ("GET" , "/user/:name" , possumHandler )
226
233
You can’t perform that action at this time.
0 commit comments