go_benchmark

package module
v0.0.0-...-a43be57 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2019 License: MIT Imports: 6 Imported by: 0

README

Go Benchmarks for JSON encoding/decoding libraries

Because the standard Golang library sometimes isn't enough...

These benchmarks are aimed at providing the latest (Dec 2019) results of various popular drop-in replacements for the Golang encoding/json library.

Originally based on jsoniter's go-benchmark, these have been go-modules-modernized and improved.

Suggestions and contributions are welcome!

Benchmark Results

go version go1.13.5 darwin/amd64

MacBook Pro (15-inch, 2018)

2.6 GHz 6-Core Intel Core i7

16 GB 2400 MHz DDR4

benchmark iter time/iter bytes/op allocs/op
BenchmarkDecodeStdStructSmall-12 469744 2334 ns/op 272 B/op 6 allocs/op
BenchmarkEncodeStdStructSmall-12 2625330 493 ns/op 192 B/op 2 allocs/op
BenchmarkDecodeSegmentioJsonStructSmall-12 1284361 889 ns/op 64 B/op 2 allocs/op
BenchmarkEncodeSegmentioJsonStructSmall-12 3632870 375 ns/op 192 B/op 2 allocs/op
BenchmarkDecodeJsoniterStructSmall-12 1963063 595 ns/op 64 B/op 2 allocs/op
BenchmarkEncodeJsoniterStructSmall-12 2650510 516 ns/op 192 B/op 2 allocs/op
BenchmarkDecodeEasyJsonSmall-12 1741574 680 ns/op 64 B/op 2 allocs/op
BenchmarkEncodeEasyJsonSmall-12 4292940 278 ns/op 128 B/op 1 allocs/op
BenchmarkDecodeStdStructMedium-12 63357 19156 ns/op 496 B/op 11 allocs/op
BenchmarkEncodeStdStructMedium-12 1625660 749 ns/op 224 B/op 2 allocs/op
BenchmarkDecodeSegmentioJsonStructMedium-12 215605 5494 ns/op 80 B/op 2 allocs/op
BenchmarkEncodeSegmentioJsonStructMedium-12 2399955 492 ns/op 224 B/op 2 allocs/op
BenchmarkDecodeJsoniterStructMedium-12 208089 5739 ns/op 384 B/op 41 allocs/op
BenchmarkEncodeJsoniterStructMedium-12 1600407 757 ns/op 224 B/op 2 allocs/op
BenchmarkDecodeEasyJsonMedium-12 163221 7059 ns/op 160 B/op 4 allocs/op
BenchmarkEncodeEasyJsonMedium-12 2135684 568 ns/op 576 B/op 3 allocs/op
BenchmarkDecodeStdStructLarge-12 5624 213245 ns/op 344 B/op 7 allocs/op
BenchmarkEncodeStdStructLarge-12 1372980 853 ns/op 160 B/op 2 allocs/op
BenchmarkDecodeSegmentioJsonStructLarge-12 13791 83988 ns/op 0 B/op 0 allocs/op
BenchmarkEncodeSegmentioJsonStructLarge-12 2916681 415 ns/op 160 B/op 2 allocs/op
BenchmarkDecodeJsoniterStructLarge-12 13924 86726 ns/op 12885 B/op 1124 allocs/op
BenchmarkEncodeJsoniterStructLarge-12 2094675 581 ns/op 160 B/op 2 allocs/op

Documentation

Overview

Package go_benchmark is a generated protocol buffer package.

It is generated from these files:

Pb.proto

It has these top-level messages:

PbTestObject
With2Fields

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CBAvatar

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

func (CBAvatar) MarshalEasyJSON

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (*CBAvatar) UnmarshalEasyJSON

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type CBGithub

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

func (CBGithub) MarshalEasyJSON

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (*CBGithub) UnmarshalEasyJSON

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type CBGravatar

type CBGravatar struct {
	Avatars []*CBAvatar `json:"avatars"`
}

func (CBGravatar) MarshalEasyJSON

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (*CBGravatar) UnmarshalEasyJSON

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type CBName

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

func (CBName) MarshalEasyJSON

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (*CBName) UnmarshalEasyJSON

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type CBPerson

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

func (CBPerson) MarshalEasyJSON

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (*CBPerson) UnmarshalEasyJSON

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type DSTopic

type DSTopic struct {
	Id   int    `json:"-"`
	Slug string `json:"-"`
}

func (DSTopic) MarshalEasyJSON

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (*DSTopic) UnmarshalEasyJSON

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type DSTopicsList

type DSTopicsList struct {
	Topics        []struct{} `json:"topics"`
	MoreTopicsUrl string     `json:"-"`
}

type DSUser

type DSUser struct {
	Username string
}

func (DSUser) MarshalEasyJSON

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (*DSUser) UnmarshalEasyJSON

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type LargePayload

type LargePayload struct {
	Users  []*DSUser     `json:"-"`
	Topics *DSTopicsList `json:"topics"`
}

type MediumPayload

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

func (MediumPayload) MarshalEasyJSON

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (*MediumPayload) UnmarshalEasyJSON

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type PbTestObject

type PbTestObject struct {
	Field1  string `protobuf:"bytes,1,opt,name=field1" json:"field1,omitempty"`
	Field2  string `protobuf:"bytes,2,opt,name=field2" json:"field2,omitempty"`
	Field3  string `protobuf:"bytes,3,opt,name=field3" json:"field3,omitempty"`
	Field4  string `protobuf:"bytes,4,opt,name=field4" json:"field4,omitempty"`
	Field5  string `protobuf:"bytes,5,opt,name=field5" json:"field5,omitempty"`
	Field6  string `protobuf:"bytes,6,opt,name=field6" json:"field6,omitempty"`
	Field7  string `protobuf:"bytes,7,opt,name=field7" json:"field7,omitempty"`
	Field8  string `protobuf:"bytes,8,opt,name=field8" json:"field8,omitempty"`
	Field9  string `protobuf:"bytes,9,opt,name=field9" json:"field9,omitempty"`
	Field10 string `protobuf:"bytes,10,opt,name=field10" json:"field10,omitempty"`
}

func (*PbTestObject) Descriptor

func (*PbTestObject) Descriptor() ([]byte, []int)

func (*PbTestObject) GetField1

func (m *PbTestObject) GetField1() string

func (*PbTestObject) GetField10

func (m *PbTestObject) GetField10() string

func (*PbTestObject) GetField2

func (m *PbTestObject) GetField2() string

func (*PbTestObject) GetField3

func (m *PbTestObject) GetField3() string

func (*PbTestObject) GetField4

func (m *PbTestObject) GetField4() string

func (*PbTestObject) GetField5

func (m *PbTestObject) GetField5() string

func (*PbTestObject) GetField6

func (m *PbTestObject) GetField6() string

func (*PbTestObject) GetField7

func (m *PbTestObject) GetField7() string

func (*PbTestObject) GetField8

func (m *PbTestObject) GetField8() string

func (*PbTestObject) GetField9

func (m *PbTestObject) GetField9() string

func (*PbTestObject) ProtoMessage

func (*PbTestObject) ProtoMessage()

func (*PbTestObject) Reset

func (m *PbTestObject) Reset()

func (*PbTestObject) String

func (m *PbTestObject) String() string

type SmallPayload

type SmallPayload struct {
	St   int    `json:"st"`
	Sid  int    `json:"-"`
	Tt   string `json:"-"`
	Gr   int    `json:"-"`
	Uuid string `json:"uuid"`
	Ip   string `json:"-"`
	Ua   string `json:"ua"`
	Tz   int    `json:"tz"`
	V    int    `json:"-"`
}

func (SmallPayload) MarshalEasyJSON

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (*SmallPayload) UnmarshalEasyJSON

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type With2Fields

type With2Fields struct {
	Field1 string `protobuf:"bytes,1,opt,name=field1" json:"field1,omitempty"`
	Field2 string `protobuf:"bytes,2,opt,name=field2" json:"field2,omitempty"`
}

func (*With2Fields) Descriptor

func (*With2Fields) Descriptor() ([]byte, []int)

func (*With2Fields) GetField1

func (m *With2Fields) GetField1() string

func (*With2Fields) GetField2

func (m *With2Fields) GetField2() string

func (*With2Fields) ProtoMessage

func (*With2Fields) ProtoMessage()

func (*With2Fields) Reset

func (m *With2Fields) Reset()

func (*With2Fields) String

func (m *With2Fields) String() string

Directories

Path Synopsis
Package Pb is a generated protocol buffer package.
Package Pb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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