summaryrefslogtreecommitdiff
path: root/compat/json/borrowed_bench_test.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@datawire.io>2022-08-14 20:52:33 -0600
committerLuke Shumaker <lukeshu@datawire.io>2022-08-17 02:02:42 -0600
commit35997d235f3bac7c3f9bcd4b8d2b26b0d88dc387 (patch)
tree47386ceb19133207508c32e3669a483b4d43e7f7 /compat/json/borrowed_bench_test.go
parent3ae8e37b8ca2b9a7769d659e134ee2711dc94b89 (diff)
Get the new borrowed tests running right [ci-skip]
Diffstat (limited to 'compat/json/borrowed_bench_test.go')
-rw-r--r--compat/json/borrowed_bench_test.go27
1 files changed, 12 insertions, 15 deletions
diff --git a/compat/json/borrowed_bench_test.go b/compat/json/borrowed_bench_test.go
index 9560914..f5595ff 100644
--- a/compat/json/borrowed_bench_test.go
+++ b/compat/json/borrowed_bench_test.go
@@ -13,14 +13,9 @@ package json
import (
"bytes"
"compress/gzip"
- "fmt"
- "internal/testenv"
"io"
"os"
- "reflect"
- "runtime"
"strings"
- "sync"
"testing"
)
@@ -42,7 +37,7 @@ type codeNode struct {
var codeJSON []byte
var codeStruct codeResponse
-func codeInit() {
+func codeInit(b *testing.B) { // MODIFIED: use the test logger
f, err := os.Open("testdata/code.json.gz")
if err != nil {
panic(err)
@@ -68,12 +63,12 @@ func codeInit() {
}
if !bytes.Equal(data, codeJSON) {
- println("different lengths", len(data), len(codeJSON))
+ b.Log("different lengths", len(data), len(codeJSON)) // MODIFIED: use the test logger
for i := 0; i < len(data) && i < len(codeJSON); i++ {
if data[i] != codeJSON[i] {
- println("re-marshal: changed at byte", i)
- println("orig: ", string(codeJSON[i-10:i+10]))
- println("new: ", string(data[i-10:i+10]))
+ b.Log("re-marshal: changed at byte", i) // MODIFIED: use the test logger
+ b.Log("orig: ", string(codeJSON[i-10:i+10])) // MODIFIED: use the test logger
+ b.Log("new: ", string(data[i-10:i+10])) // MODIFIED: use the test logger
break
}
}
@@ -85,7 +80,7 @@ func BenchmarkCodeEncoder(b *testing.B) {
b.ReportAllocs()
if codeJSON == nil {
b.StopTimer()
- codeInit()
+ codeInit(b) // MODIFIED: use the test logger
b.StartTimer()
}
b.RunParallel(func(pb *testing.PB) {
@@ -103,7 +98,7 @@ func BenchmarkCodeMarshal(b *testing.B) {
b.ReportAllocs()
if codeJSON == nil {
b.StopTimer()
- codeInit()
+ codeInit(b) // MODIFIED: use the test logger
b.StartTimer()
}
b.RunParallel(func(pb *testing.PB) {
@@ -149,7 +144,7 @@ func BenchmarkCodeDecoder(b *testing.B) {
b.ReportAllocs()
if codeJSON == nil {
b.StopTimer()
- codeInit()
+ codeInit(b) // MODIFIED: use the test logger
b.StartTimer()
}
b.RunParallel(func(pb *testing.PB) {
@@ -213,7 +208,7 @@ func BenchmarkCodeUnmarshal(b *testing.B) {
b.ReportAllocs()
if codeJSON == nil {
b.StopTimer()
- codeInit()
+ codeInit(b) // MODIFIED: use the test logger
b.StartTimer()
}
b.RunParallel(func(pb *testing.PB) {
@@ -231,7 +226,7 @@ func BenchmarkCodeUnmarshalReuse(b *testing.B) {
b.ReportAllocs()
if codeJSON == nil {
b.StopTimer()
- codeInit()
+ codeInit(b) // MODIFIED: use the test logger
b.StartTimer()
}
b.RunParallel(func(pb *testing.PB) {
@@ -326,6 +321,7 @@ func BenchmarkUnmapped(b *testing.B) {
})
}
+/* // MODIFIED: we don't have a cache
func BenchmarkTypeFieldsCache(b *testing.B) {
b.ReportAllocs()
var maxTypes int = 1e6
@@ -389,6 +385,7 @@ func BenchmarkTypeFieldsCache(b *testing.B) {
})
}
}
+*/ // MODIFIED: we don't have a cache
func BenchmarkEncodeMarshaler(b *testing.B) {
b.ReportAllocs()