Precalculate String() for fuzzed Quantity

Avoids biasing serialization results where the value is assumed to
be in canonical form already.
This commit is contained in:
Clayton Coleman 2016-05-21 21:56:55 -04:00
parent a9c3edc613
commit a24936355e
No known key found for this signature in database
GPG Key ID: 3D16906B4F1C5CB3

View File

@ -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)