Skip to content

benchmark: add encoding/json/v2 benchmarks - #292

Open
veverkap wants to merge 1 commit into
buger:masterfrom
veverkap:bench-encoding-json-v2
Open

veverkap wants to merge 1 commit into
buger:masterfrom
veverkap:bench-encoding-json-v2

Conversation

@veverkap

@veverkap veverkap commented Nov 6, 2026

Copy link
Copy Markdown

Description:

  • Adds encoding/json/v2 struct and any benchmarks for the small, medium and large payloads
  • Gated on go1.27 && goexperiment.jsonv2, so older toolchains skip the file
  • MatchCaseInsensitiveNames(true) matches v1's behavior for the untagged payload structs
  • TestJsonV2DecodesFixtures fails if the decoded fields come back empty

Benchmark before change:

N/A. These are new benchmarks. The encoding/json v1 results below are for comparison.

Benchmark after change:

Go 1.27.2, darwin/arm64, -count 1, ns/op:

v1 struct v2 struct v1 any v2 any
Small 652 529 1,395 749
Medium 4,021 3,532 10,969 5,708
Large 66,626 64,018 165,161 85,451
go test -run '^$' -bench 'EncodingJson(V2)?(Struct|Interface)' -benchmem ./benchmark/

Not run at the template's 5s benchtime. README tables not updated.

🤖 Generated with Claude Code

Struct and interface decoding for the small, medium and large payloads,
mirroring the encoding/json benchmarks. Gated on go1.27 && goexperiment.jsonv2.
MatchCaseInsensitiveNames(true) matches v1's field-name behavior for the
untagged payload structs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant