MCPcopy
hub / github.com/tinylib/msgp / BenchmarkAppendFloat

Function BenchmarkAppendFloat

msgp/write_bytes_test.go:185–204  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

183}
184
185func BenchmarkAppendFloat(b *testing.B) {
186 rng := rand.New(rand.NewSource(0))
187 const n = 1 << 16
188 src := make([]float64, n)
189 for i := range src {
190 // ~50% full float64, 50% converted from float32.
191 if rng.Uint32()&1 == 1 {
192 src[i] = rng.NormFloat64()
193 } else {
194 src[i] = float64(math.MaxFloat32 * (0.5 - rng.Float32()))
195 }
196 }
197 buf := make([]byte, 0, 9)
198 b.SetBytes(8)
199 b.ReportAllocs()
200 b.ResetTimer()
201 for i := 0; i < b.N; i++ {
202 AppendFloat(buf, src[i&(n-1)])
203 }
204}
205
206func TestAppendFloat64(t *testing.T) {
207 f := float64(3.14159)

Callers

nothing calls this directly

Calls 1

AppendFloatFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…