benchmarks

package module
v0.29.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

README

benchmarks

Disclaimer: go-openapi has no affiliation with the providers of the tested libraries.

Credits: the definition of the small, medium and large payloads has been taken from the benchmarks published at github.com/goccy/go-json. Thanks @goccy. We'd love to include your library as one of our supported adapters.

This benchmark is not a competitive benchmark, but merely a way for us to ensure that our "JSON adapter" feature runs with good performances and induces a reasonably low overhead.

Expected behavior: the Adapter layer is relatively thin: it involves no extra allocation and its CPU impact is negligible when compared to the Marshal/Unmarshal tasks.

NOTE: the FromDynamicJSON benchmark uses both source and target types supporting easyjson, which equates more or less to a deep copy of the original payload.

Using any as a target would systematically route to the standard library and therefore, results wouldn't represent a fair comparison.

go1.26.4

Benchmark go1.26.4

go version go1.26.4 linux/amd64

cpu: AMD Ryzen 7 5800X 8-Core Processor

go1.25.0

Benchmark go1.25 v0.25.0

go version go1.25.0 linux/amd64

cpu: AMD Ryzen 7 5800X 8-Core Processor

Updating benchmarks & diagrams

go install github.com/fredbi/benchviz@latest

go test -v -bench . -run Bench -benchtime 30s  -benchmem -json > bench.json

benchviz -json -strict -png -o bench bench.json

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Avatars

type Avatars []*CBAvatar

type CBAvatar

type CBAvatar struct {
	URL string `json:"url"`
}

func (CBAvatar) MarshalEasyJSON

func (v CBAvatar) MarshalEasyJSON(out *jwriter.Writer)

func (*CBAvatar) UnmarshalEasyJSON

func (v *CBAvatar) UnmarshalEasyJSON(in *jlexer.Lexer)

type CBGithub

type CBGithub struct {
	Followers int `json:"followers"`
}

func (CBGithub) MarshalEasyJSON

func (v CBGithub) MarshalEasyJSON(out *jwriter.Writer)

func (*CBGithub) UnmarshalEasyJSON

func (v *CBGithub) UnmarshalEasyJSON(in *jlexer.Lexer)

type CBGravatar

type CBGravatar struct {
	Avatars Avatars `json:"avatars"`
}

func (CBGravatar) MarshalEasyJSON

func (v CBGravatar) MarshalEasyJSON(out *jwriter.Writer)

func (*CBGravatar) UnmarshalEasyJSON

func (v *CBGravatar) UnmarshalEasyJSON(in *jlexer.Lexer)

type CBName

type CBName struct {
	FullName string `json:"fullName"`
}

func (CBName) MarshalEasyJSON

func (v CBName) MarshalEasyJSON(out *jwriter.Writer)

func (*CBName) UnmarshalEasyJSON

func (v *CBName) UnmarshalEasyJSON(in *jlexer.Lexer)

type CBPerson

type CBPerson struct {
	Name     *CBName     `json:"name"`
	Github   *CBGithub   `json:"github"`
	Gravatar *CBGravatar `json:"gravatar"`
}

func (CBPerson) MarshalEasyJSON

func (v CBPerson) MarshalEasyJSON(out *jwriter.Writer)

func (*CBPerson) UnmarshalEasyJSON

func (v *CBPerson) UnmarshalEasyJSON(in *jlexer.Lexer)

type DSTopic

type DSTopic struct {
	ID   int    `json:"id"`
	Slug string `json:"slug"`
}

func (DSTopic) MarshalEasyJSON

func (v DSTopic) MarshalEasyJSON(out *jwriter.Writer)

func (*DSTopic) UnmarshalEasyJSON

func (v *DSTopic) UnmarshalEasyJSON(in *jlexer.Lexer)

type DSTopics

type DSTopics []*DSTopic

type DSTopicsList

type DSTopicsList struct {
	Topics        DSTopics `json:"topics"`
	MoreTopicsURL string   `json:"moreTopicsURL"`
}

func (DSTopicsList) MarshalEasyJSON

func (v DSTopicsList) MarshalEasyJSON(out *jwriter.Writer)

func (*DSTopicsList) UnmarshalEasyJSON

func (v *DSTopicsList) UnmarshalEasyJSON(in *jlexer.Lexer)

type DSUser

type DSUser struct {
	Username string `json:"username"`
}

func (DSUser) MarshalEasyJSON

func (v DSUser) MarshalEasyJSON(out *jwriter.Writer)

func (*DSUser) UnmarshalEasyJSON

func (v *DSUser) UnmarshalEasyJSON(in *jlexer.Lexer)

type DSUsers

type DSUsers []*DSUser

type LargePayload

type LargePayload struct {
	Users  DSUsers       `json:"users"`
	Topics *DSTopicsList `json:"topics"`
}

func NewLargePayload

func NewLargePayload() *LargePayload

func (LargePayload) MarshalEasyJSON

func (v LargePayload) MarshalEasyJSON(out *jwriter.Writer)

func (*LargePayload) UnmarshalEasyJSON

func (v *LargePayload) UnmarshalEasyJSON(in *jlexer.Lexer)

type MediumPayload

type MediumPayload struct {
	Person  *CBPerson `json:"person"`
	Company string    `json:"company"`
}

func NewMediumPayload

func NewMediumPayload() *MediumPayload

func (MediumPayload) MarshalEasyJSON

func (v MediumPayload) MarshalEasyJSON(out *jwriter.Writer)

func (*MediumPayload) UnmarshalEasyJSON

func (v *MediumPayload) UnmarshalEasyJSON(in *jlexer.Lexer)

type SmallPayload

type SmallPayload struct {
	St   int    `json:"st"`
	Sid  int    `json:"sid"`
	Tt   string `json:"tt"`
	Gr   int    `json:"gr"`
	UUID string `json:"uuid"`
	IP   string `json:"ip"`
	Ua   string `json:"ua"`
	Tz   int    `json:"tz"`
	V    int    `json:"v"`
}

func NewSmallPayload

func NewSmallPayload() *SmallPayload

func (SmallPayload) MarshalEasyJSON

func (v SmallPayload) MarshalEasyJSON(out *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*SmallPayload) UnmarshalEasyJSON

func (v *SmallPayload) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL