(b *testing.B)
| 183 | } |
| 184 | |
| 185 | func 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 | |
| 206 | func TestAppendFloat64(t *testing.T) { |
| 207 | f := float64(3.14159) |
nothing calls this directly
no test coverage detected
searching dependent graphs…