123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701 |
- package benchmark
- import (
- json "encoding/json"
- jlexer "github.com/mailru/easyjson/jlexer"
- jwriter "github.com/mailru/easyjson/jwriter"
- )
- var _ = json.RawMessage{} // suppress unused package warning
- func easyjson_decode_github_com_buger_jsonparser_benchmark_LargePayload(in *jlexer.Lexer, out *LargePayload) {
- in.Delim('{')
- for !in.IsDelim('}') {
- key := in.UnsafeString()
- in.WantColon()
- if in.IsNull() {
- in.Skip()
- in.WantComma()
- continue
- }
- switch key {
- case "users":
- in.Delim('[')
- if !in.IsDelim(']') {
- out.Users = make([]*DSUser, 0, 8)
- } else {
- out.Users = nil
- }
- for !in.IsDelim(']') {
- var v1 *DSUser
- if in.IsNull() {
- in.Skip()
- v1 = nil
- } else {
- v1 = new(DSUser)
- (*v1).UnmarshalEasyJSON(in)
- }
- out.Users = append(out.Users, v1)
- in.WantComma()
- }
- in.Delim(']')
- case "topics":
- if in.IsNull() {
- in.Skip()
- out.Topics = nil
- } else {
- out.Topics = new(DSTopicsList)
- (*out.Topics).UnmarshalEasyJSON(in)
- }
- default:
- in.SkipRecursive()
- }
- in.WantComma()
- }
- in.Delim('}')
- }
- func easyjson_encode_github_com_buger_jsonparser_benchmark_LargePayload(out *jwriter.Writer, in *LargePayload) {
- out.RawByte('{')
- first := true
- _ = first
- if !first {
- out.RawByte(',')
- }
- first = false
- out.RawString("\"users\":")
- out.RawByte('[')
- for v2, v3 := range in.Users {
- if v2 > 0 {
- out.RawByte(',')
- }
- if v3 == nil {
- out.RawString("null")
- } else {
- (*v3).MarshalEasyJSON(out)
- }
- }
- out.RawByte(']')
- if !first {
- out.RawByte(',')
- }
- first = false
- out.RawString("\"topics\":")
- if in.Topics == nil {
- out.RawString("null")
- } else {
- (*in.Topics).MarshalEasyJSON(out)
- }
- out.RawByte('}')
- }
- func (v *LargePayload) MarshalEasyJSON(w *jwriter.Writer) {
- easyjson_encode_github_com_buger_jsonparser_benchmark_LargePayload(w, v)
- }
- func (v *LargePayload) UnmarshalEasyJSON(l *jlexer.Lexer) {
- easyjson_decode_github_com_buger_jsonparser_benchmark_LargePayload(l, v)
- }
- func easyjson_decode_github_com_buger_jsonparser_benchmark_DSTopicsList(in *jlexer.Lexer, out *DSTopicsList) {
- in.Delim('{')
- for !in.IsDelim('}') {
- key := in.UnsafeString()
- in.WantColon()
- if in.IsNull() {
- in.Skip()
- in.WantComma()
- continue
- }
- switch key {
- case "topics":
- in.Delim('[')
- if !in.IsDelim(']') {
- out.Topics = make([]*DSTopic, 0, 8)
- } else {
- out.Topics = nil
- }
- for !in.IsDelim(']') {
- var v4 *DSTopic
- if in.IsNull() {
- in.Skip()
- v4 = nil
- } else {
- v4 = new(DSTopic)
- (*v4).UnmarshalEasyJSON(in)
- }
- out.Topics = append(out.Topics, v4)
- in.WantComma()
- }
- in.Delim(']')
- case "more_topics_url":
- out.MoreTopicsUrl = in.String()
- default:
- in.SkipRecursive()
- }
- in.WantComma()
- }
- in.Delim('}')
- }
- func easyjson_encode_github_com_buger_jsonparser_benchmark_DSTopicsList(out *jwriter.Writer, in *DSTopicsList) {
- out.RawByte('{')
- first := true
- _ = first
- if !first {
- out.RawByte(',')
- }
- first = false
- out.RawString("\"topics\":")
- out.RawByte('[')
- for v5, v6 := range in.Topics {
- if v5 > 0 {
- out.RawByte(',')
- }
- if v6 == nil {
- out.RawString("null")
- } else {
- (*v6).MarshalEasyJSON(out)
- }
- }
- out.RawByte(']')
- if !first {
- out.RawByte(',')
- }
- first = false
- out.RawString("\"more_topics_url\":")
- out.String(in.MoreTopicsUrl)
- out.RawByte('}')
- }
- func (v *DSTopicsList) MarshalEasyJSON(w *jwriter.Writer) {
- easyjson_encode_github_com_buger_jsonparser_benchmark_DSTopicsList(w, v)
- }
- func (v *DSTopicsList) UnmarshalEasyJSON(l *jlexer.Lexer) {
- easyjson_decode_github_com_buger_jsonparser_benchmark_DSTopicsList(l, v)
- }
- func easyjson_decode_github_com_buger_jsonparser_benchmark_DSTopic(in *jlexer.Lexer, out *DSTopic) {
- in.Delim('{')
- for !in.IsDelim('}') {
- key := in.UnsafeString()
- in.WantColon()
- if in.IsNull() {
- in.Skip()
- in.WantComma()
- continue
- }
- switch key {
- case "id":
- out.Id = in.Int()
- case "slug":
- out.Slug = in.String()
- default:
- in.SkipRecursive()
- }
- in.WantComma()
- }
- in.Delim('}')
- }
- func easyjson_encode_github_com_buger_jsonparser_benchmark_DSTopic(out *jwriter.Writer, in *DSTopic) {
- out.RawByte('{')
- first := true
- _ = first
- if !first {
- out.RawByte(',')
- }
- first = false
- out.RawString("\"id\":")
- out.Int(in.Id)
- if !first {
- out.RawByte(',')
- }
- first = false
- out.RawString("\"slug\":")
- out.String(in.Slug)
- out.RawByte('}')
- }
- func (v *DSTopic) MarshalEasyJSON(w *jwriter.Writer) {
- easyjson_encode_github_com_buger_jsonparser_benchmark_DSTopic(w, v)
- }
- func (v *DSTopic) UnmarshalEasyJSON(l *jlexer.Lexer) {
- easyjson_decode_github_com_buger_jsonparser_benchmark_DSTopic(l, v)
- }
- func easyjson_decode_github_com_buger_jsonparser_benchmark_DSUser(in *jlexer.Lexer, out *DSUser) {
- in.Delim('{')
- for !in.IsDelim('}') {
- key := in.UnsafeString()
- in.WantColon()
- if in.IsNull() {
- in.Skip()
- in.WantComma()
- continue
- }
- switch key {
- case "username":
- out.Username = in.String()
- default:
- in.SkipRecursive()
- }
- in.WantComma()
- }
- in.Delim('}')
- }
- func easyjson_encode_github_com_buger_jsonparser_benchmark_DSUser(out *jwriter.Writer, in *DSUser) {
- out.RawByte('{')
- first := true
- _ = first
- if !first {
- out.RawByte(',')
- }
- first = false
- out.RawString("\"username\":")
- out.String(in.Username)
- out.RawByte('}')
- }
- func (v *DSUser) MarshalEasyJSON(w *jwriter.Writer) {
- easyjson_encode_github_com_buger_jsonparser_benchmark_DSUser(w, v)
- }
- func (v *DSUser) UnmarshalEasyJSON(l *jlexer.Lexer) {
- easyjson_decode_github_com_buger_jsonparser_benchmark_DSUser(l, v)
- }
- func easyjson_decode_github_com_buger_jsonparser_benchmark_MediumPayload(in *jlexer.Lexer, out *MediumPayload) {
- in.Delim('{')
- for !in.IsDelim('}') {
- key := in.UnsafeString()
- in.WantColon()
- if in.IsNull() {
- in.Skip()
- in.WantComma()
- continue
- }
- switch key {
- case "person":
- if in.IsNull() {
- in.Skip()
- out.Person = nil
- } else {
- out.Person = new(CBPerson)
- (*out.Person).UnmarshalEasyJSON(in)
- }
- case "company":
- in.Delim('{')
- if !in.IsDelim('}') {
- out.Company = make(map[string]interface{})
- } else {
- out.Company = nil
- }
- for !in.IsDelim('}') {
- key := in.String()
- in.WantColon()
- var v7 interface{}
- v7 = in.Interface()
- (out.Company)[key] = v7
- in.WantComma()
- }
- in.Delim('}')
- default:
- in.SkipRecursive()
- }
- in.WantComma()
- }
- in.Delim('}')
- }
- func easyjson_encode_github_com_buger_jsonparser_benchmark_MediumPayload(out *jwriter.Writer, in *MediumPayload) {
- out.RawByte('{')
- first := true
- _ = first
- if !first {
- out.RawByte(',')
- }
- first = false
- out.RawString("\"person\":")
- if in.Person == nil {
- out.RawString("null")
- } else {
- (*in.Person).MarshalEasyJSON(out)
- }
- if !first {
- out.RawByte(',')
- }
- first = false
- out.RawString("\"company\":")
- out.RawByte('{')
- v8_first := true
- for v8_name, v8_value := range in.Company {
- if !v8_first {
- out.RawByte(',')
- }
- v8_first = false
- out.String(v8_name)
- out.Raw(json.Marshal(v8_value))
- }
- out.RawByte('}')
- out.RawByte('}')
- }
- func (v *MediumPayload) MarshalEasyJSON(w *jwriter.Writer) {
- easyjson_encode_github_com_buger_jsonparser_benchmark_MediumPayload(w, v)
- }
- func (v *MediumPayload) UnmarshalEasyJSON(l *jlexer.Lexer) {
- easyjson_decode_github_com_buger_jsonparser_benchmark_MediumPayload(l, v)
- }
- func easyjson_decode_github_com_buger_jsonparser_benchmark_CBPerson(in *jlexer.Lexer, out *CBPerson) {
- in.Delim('{')
- for !in.IsDelim('}') {
- key := in.UnsafeString()
- in.WantColon()
- if in.IsNull() {
- in.Skip()
- in.WantComma()
- continue
- }
- switch key {
- case "name":
- if in.IsNull() {
- in.Skip()
- out.Name = nil
- } else {
- out.Name = new(CBName)
- (*out.Name).UnmarshalEasyJSON(in)
- }
- case "github":
- if in.IsNull() {
- in.Skip()
- out.Github = nil
- } else {
- out.Github = new(CBGithub)
- (*out.Github).UnmarshalEasyJSON(in)
- }
- case "gravatar":
- if in.IsNull() {
- in.Skip()
- out.Gravatar = nil
- } else {
- out.Gravatar = new(CBGravatar)
- (*out.Gravatar).UnmarshalEasyJSON(in)
- }
- default:
- in.SkipRecursive()
- }
- in.WantComma()
- }
- in.Delim('}')
- }
- func easyjson_encode_github_com_buger_jsonparser_benchmark_CBPerson(out *jwriter.Writer, in *CBPerson) {
- out.RawByte('{')
- first := true
- _ = first
- if !first {
- out.RawByte(',')
- }
- first = false
- out.RawString("\"name\":")
- if in.Name == nil {
- out.RawString("null")
- } else {
- (*in.Name).MarshalEasyJSON(out)
- }
- if !first {
- out.RawByte(',')
- }
- first = false
- out.RawString("\"github\":")
- if in.Github == nil {
- out.RawString("null")
- } else {
- (*in.Github).MarshalEasyJSON(out)
- }
- if !first {
- out.RawByte(',')
- }
- first = false
- out.RawString("\"gravatar\":")
- if in.Gravatar == nil {
- out.RawString("null")
- } else {
- (*in.Gravatar).MarshalEasyJSON(out)
- }
- out.RawByte('}')
- }
- func (v *CBPerson) MarshalEasyJSON(w *jwriter.Writer) {
- easyjson_encode_github_com_buger_jsonparser_benchmark_CBPerson(w, v)
- }
- func (v *CBPerson) UnmarshalEasyJSON(l *jlexer.Lexer) {
- easyjson_decode_github_com_buger_jsonparser_benchmark_CBPerson(l, v)
- }
- func easyjson_decode_github_com_buger_jsonparser_benchmark_CBName(in *jlexer.Lexer, out *CBName) {
- in.Delim('{')
- for !in.IsDelim('}') {
- key := in.UnsafeString()
- in.WantColon()
- if in.IsNull() {
- in.Skip()
- in.WantComma()
- continue
- }
- switch key {
- case "full_name":
- out.FullName = in.String()
- default:
- in.SkipRecursive()
- }
- in.WantComma()
- }
- in.Delim('}')
- }
- func easyjson_encode_github_com_buger_jsonparser_benchmark_CBName(out *jwriter.Writer, in *CBName) {
- out.RawByte('{')
- first := true
- _ = first
- if !first {
- out.RawByte(',')
- }
- first = false
- out.RawString("\"full_name\":")
- out.String(in.FullName)
- out.RawByte('}')
- }
- func (v *CBName) MarshalEasyJSON(w *jwriter.Writer) {
- easyjson_encode_github_com_buger_jsonparser_benchmark_CBName(w, v)
- }
- func (v *CBName) UnmarshalEasyJSON(l *jlexer.Lexer) {
- easyjson_decode_github_com_buger_jsonparser_benchmark_CBName(l, v)
- }
- func easyjson_decode_github_com_buger_jsonparser_benchmark_CBGithub(in *jlexer.Lexer, out *CBGithub) {
- in.Delim('{')
- for !in.IsDelim('}') {
- key := in.UnsafeString()
- in.WantColon()
- if in.IsNull() {
- in.Skip()
- in.WantComma()
- continue
- }
- switch key {
- case "followers":
- out.Followers = in.Int()
- default:
- in.SkipRecursive()
- }
- in.WantComma()
- }
- in.Delim('}')
- }
- func easyjson_encode_github_com_buger_jsonparser_benchmark_CBGithub(out *jwriter.Writer, in *CBGithub) {
- out.RawByte('{')
- first := true
- _ = first
- if !first {
- out.RawByte(',')
- }
- first = false
- out.RawString("\"followers\":")
- out.Int(in.Followers)
- out.RawByte('}')
- }
- func (v *CBGithub) MarshalEasyJSON(w *jwriter.Writer) {
- easyjson_encode_github_com_buger_jsonparser_benchmark_CBGithub(w, v)
- }
- func (v *CBGithub) UnmarshalEasyJSON(l *jlexer.Lexer) {
- easyjson_decode_github_com_buger_jsonparser_benchmark_CBGithub(l, v)
- }
- func easyjson_decode_github_com_buger_jsonparser_benchmark_CBGravatar(in *jlexer.Lexer, out *CBGravatar) {
- in.Delim('{')
- for !in.IsDelim('}') {
- key := in.UnsafeString()
- in.WantColon()
- if in.IsNull() {
- in.Skip()
- in.WantComma()
- continue
- }
- switch key {
- case "avatars":
- in.Delim('[')
- if !in.IsDelim(']') {
- out.Avatars = make([]*CBAvatar, 0, 8)
- } else {
- out.Avatars = nil
- }
- for !in.IsDelim(']') {
- var v9 *CBAvatar
- if in.IsNull() {
- in.Skip()
- v9 = nil
- } else {
- v9 = new(CBAvatar)
- (*v9).UnmarshalEasyJSON(in)
- }
- out.Avatars = append(out.Avatars, v9)
- in.WantComma()
- }
- in.Delim(']')
- default:
- in.SkipRecursive()
- }
- in.WantComma()
- }
- in.Delim('}')
- }
- func easyjson_encode_github_com_buger_jsonparser_benchmark_CBGravatar(out *jwriter.Writer, in *CBGravatar) {
- out.RawByte('{')
- first := true
- _ = first
- if !first {
- out.RawByte(',')
- }
- first = false
- out.RawString("\"avatars\":")
- out.RawByte('[')
- for v10, v11 := range in.Avatars {
- if v10 > 0 {
- out.RawByte(',')
- }
- if v11 == nil {
- out.RawString("null")
- } else {
- (*v11).MarshalEasyJSON(out)
- }
- }
- out.RawByte(']')
- out.RawByte('}')
- }
- func (v *CBGravatar) MarshalEasyJSON(w *jwriter.Writer) {
- easyjson_encode_github_com_buger_jsonparser_benchmark_CBGravatar(w, v)
- }
- func (v *CBGravatar) UnmarshalEasyJSON(l *jlexer.Lexer) {
- easyjson_decode_github_com_buger_jsonparser_benchmark_CBGravatar(l, v)
- }
- func easyjson_decode_github_com_buger_jsonparser_benchmark_CBAvatar(in *jlexer.Lexer, out *CBAvatar) {
- in.Delim('{')
- for !in.IsDelim('}') {
- key := in.UnsafeString()
- in.WantColon()
- if in.IsNull() {
- in.Skip()
- in.WantComma()
- continue
- }
- switch key {
- case "url":
- out.Url = in.String()
- default:
- in.SkipRecursive()
- }
- in.WantComma()
- }
- in.Delim('}')
- }
- func easyjson_encode_github_com_buger_jsonparser_benchmark_CBAvatar(out *jwriter.Writer, in *CBAvatar) {
- out.RawByte('{')
- first := true
- _ = first
- if !first {
- out.RawByte(',')
- }
- first = false
- out.RawString("\"url\":")
- out.String(in.Url)
- out.RawByte('}')
- }
- func (v *CBAvatar) MarshalEasyJSON(w *jwriter.Writer) {
- easyjson_encode_github_com_buger_jsonparser_benchmark_CBAvatar(w, v)
- }
- func (v *CBAvatar) UnmarshalEasyJSON(l *jlexer.Lexer) {
- easyjson_decode_github_com_buger_jsonparser_benchmark_CBAvatar(l, v)
- }
- func easyjson_decode_github_com_buger_jsonparser_benchmark_SmallPayload(in *jlexer.Lexer, out *SmallPayload) {
- in.Delim('{')
- for !in.IsDelim('}') {
- key := in.UnsafeString()
- in.WantColon()
- if in.IsNull() {
- in.Skip()
- in.WantComma()
- continue
- }
- switch key {
- case "st":
- out.St = in.Int()
- case "sid":
- out.Sid = in.Int()
- case "tt":
- out.Tt = in.String()
- case "gr":
- out.Gr = in.Int()
- case "uuid":
- out.Uuid = in.String()
- case "ip":
- out.Ip = in.String()
- case "ua":
- out.Ua = in.String()
- case "tz":
- out.Tz = in.Int()
- case "v":
- out.V = in.Int()
- default:
- in.SkipRecursive()
- }
- in.WantComma()
- }
- in.Delim('}')
- }
- func easyjson_encode_github_com_buger_jsonparser_benchmark_SmallPayload(out *jwriter.Writer, in *SmallPayload) {
- out.RawByte('{')
- first := true
- _ = first
- if !first {
- out.RawByte(',')
- }
- first = false
- out.RawString("\"st\":")
- out.Int(in.St)
- if !first {
- out.RawByte(',')
- }
- first = false
- out.RawString("\"sid\":")
- out.Int(in.Sid)
- if !first {
- out.RawByte(',')
- }
- first = false
- out.RawString("\"tt\":")
- out.String(in.Tt)
- if !first {
- out.RawByte(',')
- }
- first = false
- out.RawString("\"gr\":")
- out.Int(in.Gr)
- if !first {
- out.RawByte(',')
- }
- first = false
- out.RawString("\"uuid\":")
- out.String(in.Uuid)
- if !first {
- out.RawByte(',')
- }
- first = false
- out.RawString("\"ip\":")
- out.String(in.Ip)
- if !first {
- out.RawByte(',')
- }
- first = false
- out.RawString("\"ua\":")
- out.String(in.Ua)
- if !first {
- out.RawByte(',')
- }
- first = false
- out.RawString("\"tz\":")
- out.Int(in.Tz)
- if !first {
- out.RawByte(',')
- }
- first = false
- out.RawString("\"v\":")
- out.Int(in.V)
- out.RawByte('}')
- }
- func (v *SmallPayload) MarshalEasyJSON(w *jwriter.Writer) {
- easyjson_encode_github_com_buger_jsonparser_benchmark_SmallPayload(w, v)
- }
- func (v *SmallPayload) UnmarshalEasyJSON(l *jlexer.Lexer) {
- easyjson_decode_github_com_buger_jsonparser_benchmark_SmallPayload(l, v)
- }
|