From 2e59578867dcc1383078316c7c40a80e2f85656f Mon Sep 17 00:00:00 2001 From: Andy Pan Date: Mon, 6 Jan 2020 22:38:52 +0800 Subject: [PATCH] path: sync test code from httprouter --- path_test.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/path_test.go b/path_test.go index c1e6ed4f..51bb7a3b 100644 --- a/path_test.go +++ b/path_test.go @@ -6,7 +6,6 @@ package gin import ( - "runtime" "testing" "github.com/stretchr/testify/assert" @@ -77,13 +76,17 @@ func TestPathCleanMallocs(t *testing.T) { if testing.Short() { t.Skip("skipping malloc count in short mode") } - if runtime.GOMAXPROCS(0) > 1 { - t.Log("skipping AllocsPerRun checks; GOMAXPROCS>1") - return - } for _, test := range cleanTests { allocs := testing.AllocsPerRun(100, func() { cleanPath(test.result) }) assert.EqualValues(t, allocs, 0) } } + +func BenchmarkPathClean(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, test := range cleanTests { + cleanPath(test.path) + } + } +}