From a24936355e0f994ae1a55418f20a591415e60d4b Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Sat, 21 May 2016 21:56:55 -0400 Subject: [PATCH] Precalculate String() for fuzzed Quantity Avoids biasing serialization results where the value is assumed to be in canonical form already. --- pkg/api/testing/fuzzer.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/api/testing/fuzzer.go b/pkg/api/testing/fuzzer.go index 0195b47cc96..89047ae8b82 100644 --- a/pkg/api/testing/fuzzer.go +++ b/pkg/api/testing/fuzzer.go @@ -195,6 +195,8 @@ func FuzzerFor(t *testing.T, version unversioned.GroupVersion, src rand.Source) randomQuantity := func() resource.Quantity { var q resource.Quantity c.Fuzz(&q) + // precalc the string for benchmarking purposes + _ = q.String() return q } q.Limits = make(api.ResourceList)