File: decoder_bench_float_test.go

package info (click to toggle)
golang-github-francoispqt-gojay 1.2.13-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 1,456 kB
  • sloc: makefile: 86
file content (28 lines) | stat: -rw-r--r-- 575 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package benchmarks

import (
	"encoding/json"
	"testing"

	"github.com/francoispqt/gojay"
)

var bigf = []byte(`0.00058273999999999999`)

// BenchmarkBigFloatEncodingJSON decodes a big float with the standard package
func BenchmarkBigFloatEncodingJSON(b *testing.B) {
	b.ReportAllocs()
	for n := 0; n < b.N; n++ {
		var f float64
		var _ = json.Unmarshal(bigf, &f)
	}
}

// BenchmarkBigFloatGojay decodes a big float with gojay
func BenchmarkBigFloatGojay(b *testing.B) {
	b.ReportAllocs()
	for n := 0; n < b.N; n++ {
		var f float64
		var _ = gojay.Unmarshal(bigf, &f)
	}
}