From d49c2446ee98b57a158548ef0a18cc14c534f8fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Mon, 24 Jan 2022 13:21:11 +0000 Subject: [PATCH] apply benchmark suggestions by lu4p I had these ready for the PR, but forgot to push before merging. --- bench_test.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bench_test.go b/bench_test.go index 6519fff9..7af8ec28 100644 --- a/bench_test.go +++ b/bench_test.go @@ -59,9 +59,7 @@ func BenchmarkBuild(b *testing.B) { qt.Assert(b, err, qt.IsNil) // We collect extra metrics. - var userTime, systemTime int64 - - var cachedTime int64 + var cachedTime, userTime, systemTime int64 outputBin := filepath.Join(b.TempDir(), "output") sourceDir := filepath.Join(b.TempDir(), "src") @@ -109,9 +107,9 @@ func BenchmarkBuild(b *testing.B) { qt.Assert(b, rxBuiltRuntime.Match(out), qt.IsFalse) qt.Assert(b, rxBuiltMain.Match(out), qt.IsTrue) + cachedTime += time.Since(cachedStart).Nanoseconds() userTime += int64(cmd.ProcessState.UserTime()) systemTime += int64(cmd.ProcessState.SystemTime()) - cachedTime += time.Since(cachedStart).Nanoseconds() } b.ReportMetric(float64(cachedTime)/float64(b.N), "cached-ns/op") b.ReportMetric(float64(userTime)/float64(b.N), "user-ns/op")