diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-07 12:28:35 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-07 14:05:48 -0700 |
commit | 47549aa3d10808c063d45dcaa598887dadde59c5 (patch) | |
tree | 4ae21bf95c9f3b4cce97a0a0473fe622fdb393eb /compat/json | |
parent | 643cbc4d6e37d07619bec05039da1abb411d28d4 (diff) |
compat: Enable the cache benchmark
This should have been done back in 8aa12d3 (struct.go: Cache
structIndexes, 2023-01-26)
Diffstat (limited to 'compat/json')
-rw-r--r-- | compat/json/borrowed_bench_test.go | 14 | ||||
-rw-r--r-- | compat/json/compat_test.go | 6 |
2 files changed, 13 insertions, 7 deletions
diff --git a/compat/json/borrowed_bench_test.go b/compat/json/borrowed_bench_test.go index e2d74ab..443a13d 100644 --- a/compat/json/borrowed_bench_test.go +++ b/compat/json/borrowed_bench_test.go @@ -15,9 +15,13 @@ package json import ( "bytes" "compress/gzip" + "fmt" "io" "os" + "reflect" + "runtime" "strings" + "sync" "testing" ) @@ -325,11 +329,10 @@ func BenchmarkUnmapped(b *testing.B) { }) } -/* // MODIFIED: we don't have a cache func BenchmarkTypeFieldsCache(b *testing.B) { b.ReportAllocs() var maxTypes int = 1e6 - if testenv.Builder() != "" { + if false { // testenv.Builder() != "" { // MODIFIED: disabled maxTypes = 1e3 // restrict cache sizes on builders } @@ -345,9 +348,9 @@ func BenchmarkTypeFieldsCache(b *testing.B) { } // clearClear clears the cache. Other JSON operations, must not be running. - clearCache := func() { - fieldCache = sync.Map{} - } + // clearCache := func() { // MODIFIED: use function from compat_test.go + // fieldCache = sync.Map{} // MODIFIED: use function from compat_test.go + // } // MODIFIED: use function from compat_test.go // MissTypes tests the performance of repeated cache misses. // This measures the time to rebuild a cache of size nt. @@ -389,7 +392,6 @@ func BenchmarkTypeFieldsCache(b *testing.B) { }) } } -*/ // MODIFIED: we don't have a cache func BenchmarkEncodeMarshaler(b *testing.B) { b.ReportAllocs() diff --git a/compat/json/compat_test.go b/compat/json/compat_test.go index 2969107..203594f 100644 --- a/compat/json/compat_test.go +++ b/compat/json/compat_test.go @@ -14,7 +14,11 @@ import ( "git.lukeshu.com/go/lowmemjson/internal/jsontest" ) -var parseTag = jsonstruct.ParseTag +var ( + parseTag = jsonstruct.ParseTag + clearCache = jsonstruct.ClearCache + cachedTypeFields = jsonstruct.IndexStruct +) type scanner = lowmemjson.ReEncoderConfig |