vendor files

This commit is contained in:
Serguei Bezverkhi
2018-01-09 13:57:14 -05:00
parent 558bc6c02a
commit 7b24313bd6
16547 changed files with 4527373 additions and 0 deletions

View File

@ -0,0 +1,279 @@
// +build use_codec
package benchmark
import (
"testing"
"github.com/ugorji/go/codec"
)
func BenchmarkCodec_Unmarshal_M(b *testing.B) {
var h codec.Handle = new(codec.JsonHandle)
dec := codec.NewDecoderBytes(nil, h)
b.SetBytes(int64(len(largeStructText)))
for i := 0; i < b.N; i++ {
var s LargeStruct
dec.ResetBytes(largeStructText)
if err := dec.Decode(&s); err != nil {
b.Error(err)
}
}
}
func BenchmarkCodec_Unmarshal_S(b *testing.B) {
var h codec.Handle = new(codec.JsonHandle)
dec := codec.NewDecoderBytes(nil, h)
b.SetBytes(int64(len(smallStructText)))
for i := 0; i < b.N; i++ {
var s LargeStruct
dec.ResetBytes(smallStructText)
if err := dec.Decode(&s); err != nil {
b.Error(err)
}
}
}
func BenchmarkCodec_Marshal_S(b *testing.B) {
var h codec.Handle = new(codec.JsonHandle)
var out []byte
enc := codec.NewEncoderBytes(&out, h)
var l int64
for i := 0; i < b.N; i++ {
enc.ResetBytes(&out)
if err := enc.Encode(&smallStructData); err != nil {
b.Error(err)
}
l = int64(len(out))
out = nil
}
b.SetBytes(l)
}
func BenchmarkCodec_Marshal_M(b *testing.B) {
var h codec.Handle = new(codec.JsonHandle)
var out []byte
enc := codec.NewEncoderBytes(&out, h)
var l int64
for i := 0; i < b.N; i++ {
enc.ResetBytes(&out)
if err := enc.Encode(&largeStructData); err != nil {
b.Error(err)
}
l = int64(len(out))
out = nil
}
b.SetBytes(l)
}
func BenchmarkCodec_Marshal_L(b *testing.B) {
var h codec.Handle = new(codec.JsonHandle)
var out []byte
enc := codec.NewEncoderBytes(&out, h)
var l int64
for i := 0; i < b.N; i++ {
enc.ResetBytes(&out)
if err := enc.Encode(&xlStructData); err != nil {
b.Error(err)
}
l = int64(len(out))
out = nil
}
b.SetBytes(l)
}
func BenchmarkCodec_Marshal_S_Reuse(b *testing.B) {
var h codec.Handle = new(codec.JsonHandle)
var out []byte
enc := codec.NewEncoderBytes(&out, h)
var l int64
for i := 0; i < b.N; i++ {
enc.ResetBytes(&out)
if err := enc.Encode(&smallStructData); err != nil {
b.Error(err)
}
l = int64(len(out))
out = out[:0]
}
b.SetBytes(l)
}
func BenchmarkCodec_Marshal_M_Reuse(b *testing.B) {
var h codec.Handle = new(codec.JsonHandle)
var out []byte
enc := codec.NewEncoderBytes(&out, h)
var l int64
for i := 0; i < b.N; i++ {
enc.ResetBytes(&out)
if err := enc.Encode(&largeStructData); err != nil {
b.Error(err)
}
l = int64(len(out))
out = out[:0]
}
b.SetBytes(l)
}
func BenchmarkCodec_Marshal_L_Reuse(b *testing.B) {
var h codec.Handle = new(codec.JsonHandle)
var out []byte
enc := codec.NewEncoderBytes(&out, h)
var l int64
for i := 0; i < b.N; i++ {
enc.ResetBytes(&out)
if err := enc.Encode(&xlStructData); err != nil {
b.Error(err)
}
l = int64(len(out))
out = out[:0]
}
b.SetBytes(l)
}
func BenchmarkCodec_Marshal_S_Parallel(b *testing.B) {
var l int64
b.RunParallel(func(pb *testing.PB) {
var out []byte
var h codec.Handle = new(codec.JsonHandle)
enc := codec.NewEncoderBytes(&out, h)
for pb.Next() {
enc.ResetBytes(&out)
if err := enc.Encode(&smallStructData); err != nil {
b.Error(err)
}
l = int64(len(out))
out = nil
}
})
b.SetBytes(l)
}
func BenchmarkCodec_Marshal_M_Parallel(b *testing.B) {
var l int64
b.RunParallel(func(pb *testing.PB) {
var h codec.Handle = new(codec.JsonHandle)
var out []byte
enc := codec.NewEncoderBytes(&out, h)
for pb.Next() {
enc.ResetBytes(&out)
if err := enc.Encode(&largeStructData); err != nil {
b.Error(err)
}
l = int64(len(out))
out = nil
}
})
b.SetBytes(l)
}
func BenchmarkCodec_Marshal_L_Parallel(b *testing.B) {
var l int64
b.RunParallel(func(pb *testing.PB) {
var h codec.Handle = new(codec.JsonHandle)
var out []byte
enc := codec.NewEncoderBytes(&out, h)
for pb.Next() {
enc.ResetBytes(&out)
if err := enc.Encode(&xlStructData); err != nil {
b.Error(err)
}
l = int64(len(out))
out = nil
}
})
b.SetBytes(l)
}
func BenchmarkCodec_Marshal_S_Parallel_Reuse(b *testing.B) {
var l int64
b.RunParallel(func(pb *testing.PB) {
var out []byte
var h codec.Handle = new(codec.JsonHandle)
enc := codec.NewEncoderBytes(&out, h)
for pb.Next() {
enc.ResetBytes(&out)
if err := enc.Encode(&smallStructData); err != nil {
b.Error(err)
}
l = int64(len(out))
out = out[:0]
}
})
b.SetBytes(l)
}
func BenchmarkCodec_Marshal_M_Parallel_Reuse(b *testing.B) {
var l int64
b.RunParallel(func(pb *testing.PB) {
var h codec.Handle = new(codec.JsonHandle)
var out []byte
enc := codec.NewEncoderBytes(&out, h)
for pb.Next() {
enc.ResetBytes(&out)
if err := enc.Encode(&largeStructData); err != nil {
b.Error(err)
}
l = int64(len(out))
out = out[:0]
}
})
b.SetBytes(l)
}
func BenchmarkCodec_Marshal_L_Parallel_Reuse(b *testing.B) {
var l int64
b.RunParallel(func(pb *testing.PB) {
var h codec.Handle = new(codec.JsonHandle)
var out []byte
enc := codec.NewEncoderBytes(&out, h)
for pb.Next() {
enc.ResetBytes(&out)
if err := enc.Encode(&xlStructData); err != nil {
b.Error(err)
}
l = int64(len(out))
out = out[:0]
}
})
b.SetBytes(l)
}

148
vendor/github.com/mailru/easyjson/benchmark/data.go generated vendored Normal file
View File

@ -0,0 +1,148 @@
// Package benchmark provides a simple benchmark for easyjson against default serialization and ffjson.
// The data example is taken from https://dev.twitter.com/rest/reference/get/search/tweets
package benchmark
import (
"io/ioutil"
)
var largeStructText, _ = ioutil.ReadFile("example.json")
var xlStructData XLStruct
func init() {
for i := 0; i < 50; i++ {
xlStructData.Data = append(xlStructData.Data, largeStructData)
}
}
var smallStructText = []byte(`{"hashtags":[{"indices":[5, 10],"text":"some-text"}],"urls":[],"user_mentions":[]}`)
var smallStructData = Entities{
Hashtags: []Hashtag{{Indices: []int{5, 10}, Text: "some-text"}},
Urls: []*string{},
UserMentions: []*string{},
}
type SearchMetadata struct {
CompletedIn float64 `json:"completed_in"`
Count int `json:"count"`
MaxID int64 `json:"max_id"`
MaxIDStr string `json:"max_id_str"`
NextResults string `json:"next_results"`
Query string `json:"query"`
RefreshURL string `json:"refresh_url"`
SinceID int64 `json:"since_id"`
SinceIDStr string `json:"since_id_str"`
}
type Hashtag struct {
Indices []int `json:"indices"`
Text string `json:"text"`
}
//easyjson:json
type Entities struct {
Hashtags []Hashtag `json:"hashtags"`
Urls []*string `json:"urls"`
UserMentions []*string `json:"user_mentions"`
}
type UserEntityDescription struct {
Urls []*string `json:"urls"`
}
type URL struct {
ExpandedURL *string `json:"expanded_url"`
Indices []int `json:"indices"`
URL string `json:"url"`
}
type UserEntityURL struct {
Urls []URL `json:"urls"`
}
type UserEntities struct {
Description UserEntityDescription `json:"description"`
URL UserEntityURL `json:"url"`
}
type User struct {
ContributorsEnabled bool `json:"contributors_enabled"`
CreatedAt string `json:"created_at"`
DefaultProfile bool `json:"default_profile"`
DefaultProfileImage bool `json:"default_profile_image"`
Description string `json:"description"`
Entities UserEntities `json:"entities"`
FavouritesCount int `json:"favourites_count"`
FollowRequestSent *string `json:"follow_request_sent"`
FollowersCount int `json:"followers_count"`
Following *string `json:"following"`
FriendsCount int `json:"friends_count"`
GeoEnabled bool `json:"geo_enabled"`
ID int `json:"id"`
IDStr string `json:"id_str"`
IsTranslator bool `json:"is_translator"`
Lang string `json:"lang"`
ListedCount int `json:"listed_count"`
Location string `json:"location"`
Name string `json:"name"`
Notifications *string `json:"notifications"`
ProfileBackgroundColor string `json:"profile_background_color"`
ProfileBackgroundImageURL string `json:"profile_background_image_url"`
ProfileBackgroundImageURLHTTPS string `json:"profile_background_image_url_https"`
ProfileBackgroundTile bool `json:"profile_background_tile"`
ProfileImageURL string `json:"profile_image_url"`
ProfileImageURLHTTPS string `json:"profile_image_url_https"`
ProfileLinkColor string `json:"profile_link_color"`
ProfileSidebarBorderColor string `json:"profile_sidebar_border_color"`
ProfileSidebarFillColor string `json:"profile_sidebar_fill_color"`
ProfileTextColor string `json:"profile_text_color"`
ProfileUseBackgroundImage bool `json:"profile_use_background_image"`
Protected bool `json:"protected"`
ScreenName string `json:"screen_name"`
ShowAllInlineMedia bool `json:"show_all_inline_media"`
StatusesCount int `json:"statuses_count"`
TimeZone string `json:"time_zone"`
URL *string `json:"url"`
UtcOffset int `json:"utc_offset"`
Verified bool `json:"verified"`
}
type StatusMetadata struct {
IsoLanguageCode string `json:"iso_language_code"`
ResultType string `json:"result_type"`
}
type Status struct {
Contributors *string `json:"contributors"`
Coordinates *string `json:"coordinates"`
CreatedAt string `json:"created_at"`
Entities Entities `json:"entities"`
Favorited bool `json:"favorited"`
Geo *string `json:"geo"`
ID int64 `json:"id"`
IDStr string `json:"id_str"`
InReplyToScreenName *string `json:"in_reply_to_screen_name"`
InReplyToStatusID *string `json:"in_reply_to_status_id"`
InReplyToStatusIDStr *string `json:"in_reply_to_status_id_str"`
InReplyToUserID *string `json:"in_reply_to_user_id"`
InReplyToUserIDStr *string `json:"in_reply_to_user_id_str"`
Metadata StatusMetadata `json:"metadata"`
Place *string `json:"place"`
RetweetCount int `json:"retweet_count"`
Retweeted bool `json:"retweeted"`
Source string `json:"source"`
Text string `json:"text"`
Truncated bool `json:"truncated"`
User User `json:"user"`
}
//easyjson:json
type LargeStruct struct {
SearchMetadata SearchMetadata `json:"search_metadata"`
Statuses []Status `json:"statuses"`
}
//easyjson:json
type XLStruct struct {
Data []LargeStruct
}

6914
vendor/github.com/mailru/easyjson/benchmark/data_codec.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

350
vendor/github.com/mailru/easyjson/benchmark/data_var.go generated vendored Normal file
View File

@ -0,0 +1,350 @@
package benchmark
var largeStructData = LargeStruct{
SearchMetadata: SearchMetadata{
CompletedIn: 0.035,
Count: 4,
MaxID: 250126199840518145,
MaxIDStr: "250126199840518145",
NextResults: "?max_id=249279667666817023&q=%23freebandnames&count=4&include_entities=1&result_type=mixed",
Query: "%23freebandnames",
RefreshURL: "?since_id=250126199840518145&q=%23freebandnames&result_type=mixed&include_entities=1",
SinceID: 24012619984051000,
SinceIDStr: "24012619984051000",
},
Statuses: []Status{
{
Contributors: nil,
Coordinates: nil,
CreatedAt: "Mon Sep 24 03:35:21 +0000 2012",
Entities: Entities{
Hashtags: []Hashtag{{
Indices: []int{20, 34},
Text: "freebandnames"},
},
Urls: []*string{},
UserMentions: []*string{},
},
Favorited: false,
Geo: nil,
ID: 250075927172759552,
IDStr: "250075927172759552",
InReplyToScreenName: nil,
InReplyToStatusID: nil,
InReplyToStatusIDStr: nil,
InReplyToUserID: nil,
InReplyToUserIDStr: nil,
Metadata: StatusMetadata{
IsoLanguageCode: "en",
ResultType: "recent",
},
Place: nil,
RetweetCount: 0,
Retweeted: false,
Source: "<a href=\"//itunes.apple.com/us/app/twitter/id409789998?mt=12%5C%22\" rel=\"\\\"nofollow\\\"\">Twitter for Mac</a>",
Text: "Aggressive Ponytail #freebandnames",
Truncated: false,
User: User{
ContributorsEnabled: false,
CreatedAt: "Mon Apr 26 06:01:55 +0000 2010",
DefaultProfile: true,
DefaultProfileImage: false,
Description: "Born 330 Live 310",
Entities: UserEntities{
Description: UserEntityDescription{
Urls: []*string{},
},
URL: UserEntityURL{
Urls: []URL{{
ExpandedURL: nil,
Indices: []int{0, 0},
URL: "",
}},
},
},
FavouritesCount: 0,
FollowRequestSent: nil,
FollowersCount: 70,
Following: nil,
FriendsCount: 110,
GeoEnabled: true,
ID: 137238150,
IDStr: "137238150",
IsTranslator: false,
Lang: "en",
ListedCount: 2,
Location: "LA, CA",
Name: "Sean Cummings",
Notifications: nil,
ProfileBackgroundColor: "C0DEED",
ProfileBackgroundImageURL: "http://a0.twimg.com/images/themes/theme1/bg.png",
ProfileBackgroundImageURLHTTPS: "https://si0.twimg.com/images/themes/theme1/bg.png",
ProfileBackgroundTile: false,
ProfileImageURL: "http://a0.twimg.com/profile_images/2359746665/1v6zfgqo8g0d3mk7ii5s_normal.jpeg",
ProfileImageURLHTTPS: "https://si0.twimg.com/profile_images/2359746665/1v6zfgqo8g0d3mk7ii5s_normal.jpeg",
ProfileLinkColor: "0084B4",
ProfileSidebarBorderColor: "C0DEED",
ProfileSidebarFillColor: "DDEEF6",
ProfileTextColor: "333333",
ProfileUseBackgroundImage: true,
Protected: false,
ScreenName: "sean_cummings",
ShowAllInlineMedia: false,
StatusesCount: 579,
TimeZone: "Pacific Time (US & Canada)",
URL: nil,
UtcOffset: -28800,
Verified: false,
},
},
{
Contributors: nil,
Coordinates: nil,
CreatedAt: "Fri Sep 21 23:40:54 +0000 2012",
Entities: Entities{
Hashtags: []Hashtag{{
Indices: []int{20, 34},
Text: "FreeBandNames",
}},
Urls: []*string{},
UserMentions: []*string{},
},
Favorited: false,
Geo: nil,
ID: 249292149810667520,
IDStr: "249292149810667520",
InReplyToScreenName: nil,
InReplyToStatusID: nil,
InReplyToStatusIDStr: nil,
InReplyToUserID: nil,
InReplyToUserIDStr: nil,
Metadata: StatusMetadata{
IsoLanguageCode: "pl",
ResultType: "recent",
},
Place: nil,
RetweetCount: 0,
Retweeted: false,
Source: "web",
Text: "Thee Namaste Nerdz. #FreeBandNames",
Truncated: false,
User: User{
ContributorsEnabled: false,
CreatedAt: "Tue Apr 07 19:05:07 +0000 2009",
DefaultProfile: false,
DefaultProfileImage: false,
Description: "You will come to Durham, North Carolina. I will sell you some records then, here in Durham, North Carolina. Fun will happen.",
Entities: UserEntities{
Description: UserEntityDescription{Urls: []*string{}},
URL: UserEntityURL{
Urls: []URL{{
ExpandedURL: nil,
Indices: []int{0, 32},
URL: "http://bullcityrecords.com/wnng/"}},
},
},
FavouritesCount: 8,
FollowRequestSent: nil,
FollowersCount: 2052,
Following: nil,
FriendsCount: 348,
GeoEnabled: false,
ID: 29516238,
IDStr: "29516238",
IsTranslator: false,
Lang: "en",
ListedCount: 118,
Location: "Durham, NC",
Name: "Chaz Martenstein",
Notifications: nil,
ProfileBackgroundColor: "9AE4E8",
ProfileBackgroundImageURL: "http://a0.twimg.com/profile_background_images/9423277/background_tile.bmp",
ProfileBackgroundImageURLHTTPS: "https://si0.twimg.com/profile_background_images/9423277/background_tile.bmp",
ProfileBackgroundTile: true,
ProfileImageURL: "http://a0.twimg.com/profile_images/447958234/Lichtenstein_normal.jpg",
ProfileImageURLHTTPS: "https://si0.twimg.com/profile_images/447958234/Lichtenstein_normal.jpg",
ProfileLinkColor: "0084B4",
ProfileSidebarBorderColor: "BDDCAD",
ProfileSidebarFillColor: "DDFFCC",
ProfileTextColor: "333333",
ProfileUseBackgroundImage: true,
Protected: false,
ScreenName: "bullcityrecords",
ShowAllInlineMedia: true,
StatusesCount: 7579,
TimeZone: "Eastern Time (US & Canada)",
URL: nil,
UtcOffset: -18000,
Verified: false,
},
},
Status{
Contributors: nil,
Coordinates: nil,
CreatedAt: "Fri Sep 21 23:30:20 +0000 2012",
Entities: Entities{
Hashtags: []Hashtag{{
Indices: []int{29, 43},
Text: "freebandnames",
}},
Urls: []*string{},
UserMentions: []*string{},
},
Favorited: false,
Geo: nil,
ID: 249289491129438208,
IDStr: "249289491129438208",
InReplyToScreenName: nil,
InReplyToStatusID: nil,
InReplyToStatusIDStr: nil,
InReplyToUserID: nil,
InReplyToUserIDStr: nil,
Metadata: StatusMetadata{
IsoLanguageCode: "en",
ResultType: "recent",
},
Place: nil,
RetweetCount: 0,
Retweeted: false,
Source: "web",
Text: "Mexican Heaven, Mexican Hell #freebandnames",
Truncated: false,
User: User{
ContributorsEnabled: false,
CreatedAt: "Tue Sep 01 21:21:35 +0000 2009",
DefaultProfile: false,
DefaultProfileImage: false,
Description: "Science Fiction Writer, sort of. Likes Superheroes, Mole People, Alt. Timelines.",
Entities: UserEntities{
Description: UserEntityDescription{
Urls: nil,
},
URL: UserEntityURL{
Urls: []URL{{
ExpandedURL: nil,
Indices: []int{0, 0},
URL: "",
}},
},
},
FavouritesCount: 19,
FollowRequestSent: nil,
FollowersCount: 63,
Following: nil,
FriendsCount: 63,
GeoEnabled: false,
ID: 70789458,
IDStr: "70789458",
IsTranslator: false,
Lang: "en",
ListedCount: 1,
Location: "Kingston New York",
Name: "Thomas John Wakeman",
Notifications: nil,
ProfileBackgroundColor: "352726",
ProfileBackgroundImageURL: "http://a0.twimg.com/images/themes/theme5/bg.gif",
ProfileBackgroundImageURLHTTPS: "https://si0.twimg.com/images/themes/theme5/bg.gif",
ProfileBackgroundTile: false,
ProfileImageURL: "http://a0.twimg.com/profile_images/2219333930/Froggystyle_normal.png",
ProfileImageURLHTTPS: "https://si0.twimg.com/profile_images/2219333930/Froggystyle_normal.png",
ProfileLinkColor: "D02B55",
ProfileSidebarBorderColor: "829D5E",
ProfileSidebarFillColor: "99CC33",
ProfileTextColor: "3E4415",
ProfileUseBackgroundImage: true,
Protected: false,
ScreenName: "MonkiesFist",
ShowAllInlineMedia: false,
StatusesCount: 1048,
TimeZone: "Eastern Time (US & Canada)",
URL: nil,
UtcOffset: -18000,
Verified: false,
},
},
Status{
Contributors: nil,
Coordinates: nil,
CreatedAt: "Fri Sep 21 22:51:18 +0000 2012",
Entities: Entities{
Hashtags: []Hashtag{{
Indices: []int{20, 34},
Text: "freebandnames",
}},
Urls: []*string{},
UserMentions: []*string{},
},
Favorited: false,
Geo: nil,
ID: 249279667666817024,
IDStr: "249279667666817024",
InReplyToScreenName: nil,
InReplyToStatusID: nil,
InReplyToStatusIDStr: nil,
InReplyToUserID: nil,
InReplyToUserIDStr: nil,
Metadata: StatusMetadata{
IsoLanguageCode: "en",
ResultType: "recent",
},
Place: nil,
RetweetCount: 0,
Retweeted: false,
Source: "<a href=\"//twitter.com/download/iphone%5C%22\" rel=\"\\\"nofollow\\\"\">Twitter for iPhone</a>",
Text: "The Foolish Mortals #freebandnames",
Truncated: false,
User: User{
ContributorsEnabled: false,
CreatedAt: "Mon May 04 00:05:00 +0000 2009",
DefaultProfile: false,
DefaultProfileImage: false,
Description: "Cartoonist, Illustrator, and T-Shirt connoisseur",
Entities: UserEntities{
Description: UserEntityDescription{
Urls: []*string{},
},
URL: UserEntityURL{
Urls: []URL{{
ExpandedURL: nil,
Indices: []int{0, 24},
URL: "http://www.omnitarian.me",
}},
},
},
FavouritesCount: 647,
FollowRequestSent: nil,
FollowersCount: 608,
Following: nil,
FriendsCount: 249,
GeoEnabled: false,
ID: 37539828,
IDStr: "37539828",
IsTranslator: false,
Lang: "en",
ListedCount: 52,
Location: "Wisconsin, USA",
Name: "Marty Elmer",
Notifications: nil,
ProfileBackgroundColor: "EEE3C4",
ProfileBackgroundImageURL: "http://a0.twimg.com/profile_background_images/106455659/rect6056-9.png",
ProfileBackgroundImageURLHTTPS: "https://si0.twimg.com/profile_background_images/106455659/rect6056-9.png",
ProfileBackgroundTile: true,
ProfileImageURL: "http://a0.twimg.com/profile_images/1629790393/shrinker_2000_trans_normal.png",
ProfileImageURLHTTPS: "https://si0.twimg.com/profile_images/1629790393/shrinker_2000_trans_normal.png",
ProfileLinkColor: "3B2A26",
ProfileSidebarBorderColor: "615A44",
ProfileSidebarFillColor: "BFAC83",
ProfileTextColor: "000000",
ProfileUseBackgroundImage: true,
Protected: false,
ScreenName: "Omnitarian",
ShowAllInlineMedia: true,
StatusesCount: 3575,
TimeZone: "Central Time (US & Canada)",
URL: nil,
UtcOffset: -21600,
Verified: false,
},
},
},
}

View File

@ -0,0 +1,118 @@
// +build !use_easyjson,!use_ffjson,!use_codec,!use_jsoniter
package benchmark
import (
"encoding/json"
"testing"
)
func BenchmarkStd_Unmarshal_M(b *testing.B) {
b.SetBytes(int64(len(largeStructText)))
for i := 0; i < b.N; i++ {
var s LargeStruct
err := json.Unmarshal(largeStructText, &s)
if err != nil {
b.Error(err)
}
}
}
func BenchmarkStd_Unmarshal_S(b *testing.B) {
for i := 0; i < b.N; i++ {
var s Entities
err := json.Unmarshal(smallStructText, &s)
if err != nil {
b.Error(err)
}
}
b.SetBytes(int64(len(smallStructText)))
}
func BenchmarkStd_Marshal_M(b *testing.B) {
var l int64
for i := 0; i < b.N; i++ {
data, err := json.Marshal(&largeStructData)
if err != nil {
b.Error(err)
}
l = int64(len(data))
}
b.SetBytes(l)
}
func BenchmarkStd_Marshal_L(b *testing.B) {
var l int64
for i := 0; i < b.N; i++ {
data, err := json.Marshal(&xlStructData)
if err != nil {
b.Error(err)
}
l = int64(len(data))
}
b.SetBytes(l)
}
func BenchmarkStd_Marshal_M_Parallel(b *testing.B) {
var l int64
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
data, err := json.Marshal(&largeStructData)
if err != nil {
b.Error(err)
}
l = int64(len(data))
}
})
b.SetBytes(l)
}
func BenchmarkStd_Marshal_L_Parallel(b *testing.B) {
var l int64
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
data, err := json.Marshal(&xlStructData)
if err != nil {
b.Error(err)
}
l = int64(len(data))
}
})
b.SetBytes(l)
}
func BenchmarkStd_Marshal_S(b *testing.B) {
var l int64
for i := 0; i < b.N; i++ {
data, err := json.Marshal(&smallStructData)
if err != nil {
b.Error(err)
}
l = int64(len(data))
}
b.SetBytes(l)
}
func BenchmarkStd_Marshal_S_Parallel(b *testing.B) {
var l int64
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
data, err := json.Marshal(&smallStructData)
if err != nil {
b.Error(err)
}
l = int64(len(data))
}
})
b.SetBytes(l)
}
func BenchmarkStd_Marshal_M_ToWriter(b *testing.B) {
enc := json.NewEncoder(&DummyWriter{})
for i := 0; i < b.N; i++ {
err := enc.Encode(&largeStructData)
if err != nil {
b.Error(err)
}
}
}

View File

@ -0,0 +1,11 @@
package benchmark
import (
"testing"
)
type DummyWriter struct{}
func (w DummyWriter) Write(data []byte) (int, error) { return len(data), nil }
func TestToSuppressNoTestsWarning(t *testing.T) {}

View File

@ -0,0 +1,184 @@
// +build use_easyjson
package benchmark
import (
"testing"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jwriter"
)
func BenchmarkEJ_Unmarshal_M(b *testing.B) {
b.SetBytes(int64(len(largeStructText)))
for i := 0; i < b.N; i++ {
var s LargeStruct
err := s.UnmarshalJSON(largeStructText)
if err != nil {
b.Error(err)
}
}
}
func BenchmarkEJ_Unmarshal_S(b *testing.B) {
b.SetBytes(int64(len(smallStructText)))
for i := 0; i < b.N; i++ {
var s Entities
err := s.UnmarshalJSON(smallStructText)
if err != nil {
b.Error(err)
}
}
}
func BenchmarkEJ_Marshal_M(b *testing.B) {
var l int64
for i := 0; i < b.N; i++ {
data, err := easyjson.Marshal(&largeStructData)
if err != nil {
b.Error(err)
}
l = int64(len(data))
}
b.SetBytes(l)
}
func BenchmarkEJ_Marshal_L(b *testing.B) {
var l int64
for i := 0; i < b.N; i++ {
data, err := easyjson.Marshal(&xlStructData)
if err != nil {
b.Error(err)
}
l = int64(len(data))
}
b.SetBytes(l)
}
func BenchmarkEJ_Marshal_L_ToWriter(b *testing.B) {
var l int64
out := &DummyWriter{}
for i := 0; i < b.N; i++ {
w := jwriter.Writer{}
xlStructData.MarshalEasyJSON(&w)
if w.Error != nil {
b.Error(w.Error)
}
l = int64(w.Size())
w.DumpTo(out)
}
b.SetBytes(l)
}
func BenchmarkEJ_Marshal_M_Parallel(b *testing.B) {
b.SetBytes(int64(len(largeStructText)))
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
_, err := largeStructData.MarshalJSON()
if err != nil {
b.Error(err)
}
}
})
}
func BenchmarkEJ_Marshal_M_ToWriter(b *testing.B) {
var l int64
out := &DummyWriter{}
for i := 0; i < b.N; i++ {
w := jwriter.Writer{}
largeStructData.MarshalEasyJSON(&w)
if w.Error != nil {
b.Error(w.Error)
}
l = int64(w.Size())
w.DumpTo(out)
}
b.SetBytes(l)
}
func BenchmarkEJ_Marshal_M_ToWriter_Parallel(b *testing.B) {
out := &DummyWriter{}
b.RunParallel(func(pb *testing.PB) {
var l int64
for pb.Next() {
w := jwriter.Writer{}
largeStructData.MarshalEasyJSON(&w)
if w.Error != nil {
b.Error(w.Error)
}
l = int64(w.Size())
w.DumpTo(out)
}
if l > 0 {
b.SetBytes(l)
}
})
}
func BenchmarkEJ_Marshal_L_Parallel(b *testing.B) {
var l int64
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
data, err := xlStructData.MarshalJSON()
if err != nil {
b.Error(err)
}
l = int64(len(data))
}
})
b.SetBytes(l)
}
func BenchmarkEJ_Marshal_L_ToWriter_Parallel(b *testing.B) {
out := &DummyWriter{}
b.RunParallel(func(pb *testing.PB) {
var l int64
for pb.Next() {
w := jwriter.Writer{}
xlStructData.MarshalEasyJSON(&w)
if w.Error != nil {
b.Error(w.Error)
}
l = int64(w.Size())
w.DumpTo(out)
}
if l > 0 {
b.SetBytes(l)
}
})
}
func BenchmarkEJ_Marshal_S(b *testing.B) {
var l int64
for i := 0; i < b.N; i++ {
data, err := smallStructData.MarshalJSON()
if err != nil {
b.Error(err)
}
l = int64(len(data))
}
b.SetBytes(l)
}
func BenchmarkEJ_Marshal_S_Parallel(b *testing.B) {
var l int64
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
data, err := smallStructData.MarshalJSON()
if err != nil {
b.Error(err)
}
l = int64(len(data))
}
})
b.SetBytes(l)
}

View File

@ -0,0 +1,415 @@
{
"statuses": [
{
"coordinates": null,
"favorited": false,
"truncated": false,
"created_at": "Mon Sep 24 03:35:21 +0000 2012",
"id_str": "250075927172759552",
"entities": {
"urls": [
],
"hashtags": [
{
"text": "freebandnames",
"indices": [
20,
34
]
}
],
"user_mentions": [
]
},
"in_reply_to_user_id_str": null,
"contributors": null,
"text": "Aggressive Ponytail #freebandnames",
"metadata": {
"iso_language_code": "en",
"result_type": "recent"
},
"retweet_count": 0,
"in_reply_to_status_id_str": null,
"id": 250075927172759552,
"geo": null,
"retweeted": false,
"in_reply_to_user_id": null,
"place": null,
"user": {
"profile_sidebar_fill_color": "DDEEF6",
"profile_sidebar_border_color": "C0DEED",
"profile_background_tile": false,
"name": "Sean Cummings",
"profile_image_url": "http://a0.twimg.com/profile_images/2359746665/1v6zfgqo8g0d3mk7ii5s_normal.jpeg",
"created_at": "Mon Apr 26 06:01:55 +0000 2010",
"location": "LA, CA",
"follow_request_sent": null,
"profile_link_color": "0084B4",
"is_translator": false,
"id_str": "137238150",
"entities": {
"url": {
"urls": [
{
"expanded_url": null,
"url": "",
"indices": [
0,
0
]
}
]
},
"description": {
"urls": [
]
}
},
"default_profile": true,
"contributors_enabled": false,
"favourites_count": 0,
"url": null,
"profile_image_url_https": "https://si0.twimg.com/profile_images/2359746665/1v6zfgqo8g0d3mk7ii5s_normal.jpeg",
"utc_offset": -28800,
"id": 137238150,
"profile_use_background_image": true,
"listed_count": 2,
"profile_text_color": "333333",
"lang": "en",
"followers_count": 70,
"protected": false,
"notifications": null,
"profile_background_image_url_https": "https://si0.twimg.com/images/themes/theme1/bg.png",
"profile_background_color": "C0DEED",
"verified": false,
"geo_enabled": true,
"time_zone": "Pacific Time (US & Canada)",
"description": "Born 330 Live 310",
"default_profile_image": false,
"profile_background_image_url": "http://a0.twimg.com/images/themes/theme1/bg.png",
"statuses_count": 579,
"friends_count": 110,
"following": null,
"show_all_inline_media": false,
"screen_name": "sean_cummings"
},
"in_reply_to_screen_name": null,
"source": "<a href=\"//itunes.apple.com/us/app/twitter/id409789998?mt=12%5C%22\" rel=\"\\\"nofollow\\\"\">Twitter for Mac</a>",
"in_reply_to_status_id": null
},
{
"coordinates": null,
"favorited": false,
"truncated": false,
"created_at": "Fri Sep 21 23:40:54 +0000 2012",
"id_str": "249292149810667520",
"entities": {
"urls": [
],
"hashtags": [
{
"text": "FreeBandNames",
"indices": [
20,
34
]
}
],
"user_mentions": [
]
},
"in_reply_to_user_id_str": null,
"contributors": null,
"text": "Thee Namaste Nerdz. #FreeBandNames",
"metadata": {
"iso_language_code": "pl",
"result_type": "recent"
},
"retweet_count": 0,
"in_reply_to_status_id_str": null,
"id": 249292149810667520,
"geo": null,
"retweeted": false,
"in_reply_to_user_id": null,
"place": null,
"user": {
"profile_sidebar_fill_color": "DDFFCC",
"profile_sidebar_border_color": "BDDCAD",
"profile_background_tile": true,
"name": "Chaz Martenstein",
"profile_image_url": "http://a0.twimg.com/profile_images/447958234/Lichtenstein_normal.jpg",
"created_at": "Tue Apr 07 19:05:07 +0000 2009",
"location": "Durham, NC",
"follow_request_sent": null,
"profile_link_color": "0084B4",
"is_translator": false,
"id_str": "29516238",
"entities": {
"url": {
"urls": [
{
"expanded_url": null,
"url": "http://bullcityrecords.com/wnng/",
"indices": [
0,
32
]
}
]
},
"description": {
"urls": [
]
}
},
"default_profile": false,
"contributors_enabled": false,
"favourites_count": 8,
"url": "http://bullcityrecords.com/wnng/",
"profile_image_url_https": "https://si0.twimg.com/profile_images/447958234/Lichtenstein_normal.jpg",
"utc_offset": -18000,
"id": 29516238,
"profile_use_background_image": true,
"listed_count": 118,
"profile_text_color": "333333",
"lang": "en",
"followers_count": 2052,
"protected": false,
"notifications": null,
"profile_background_image_url_https": "https://si0.twimg.com/profile_background_images/9423277/background_tile.bmp",
"profile_background_color": "9AE4E8",
"verified": false,
"geo_enabled": false,
"time_zone": "Eastern Time (US & Canada)",
"description": "You will come to Durham, North Carolina. I will sell you some records then, here in Durham, North Carolina. Fun will happen.",
"default_profile_image": false,
"profile_background_image_url": "http://a0.twimg.com/profile_background_images/9423277/background_tile.bmp",
"statuses_count": 7579,
"friends_count": 348,
"following": null,
"show_all_inline_media": true,
"screen_name": "bullcityrecords"
},
"in_reply_to_screen_name": null,
"source": "web",
"in_reply_to_status_id": null
},
{
"coordinates": null,
"favorited": false,
"truncated": false,
"created_at": "Fri Sep 21 23:30:20 +0000 2012",
"id_str": "249289491129438208",
"entities": {
"urls": [
],
"hashtags": [
{
"text": "freebandnames",
"indices": [
29,
43
]
}
],
"user_mentions": [
]
},
"in_reply_to_user_id_str": null,
"contributors": null,
"text": "Mexican Heaven, Mexican Hell #freebandnames",
"metadata": {
"iso_language_code": "en",
"result_type": "recent"
},
"retweet_count": 0,
"in_reply_to_status_id_str": null,
"id": 249289491129438208,
"geo": null,
"retweeted": false,
"in_reply_to_user_id": null,
"place": null,
"user": {
"profile_sidebar_fill_color": "99CC33",
"profile_sidebar_border_color": "829D5E",
"profile_background_tile": false,
"name": "Thomas John Wakeman",
"profile_image_url": "http://a0.twimg.com/profile_images/2219333930/Froggystyle_normal.png",
"created_at": "Tue Sep 01 21:21:35 +0000 2009",
"location": "Kingston New York",
"follow_request_sent": null,
"profile_link_color": "D02B55",
"is_translator": false,
"id_str": "70789458",
"entities": {
"url": {
"urls": [
{
"expanded_url": null,
"url": "",
"indices": [
0,
0
]
}
]
},
"description": {
"urls": [
]
}
},
"default_profile": false,
"contributors_enabled": false,
"favourites_count": 19,
"url": null,
"profile_image_url_https": "https://si0.twimg.com/profile_images/2219333930/Froggystyle_normal.png",
"utc_offset": -18000,
"id": 70789458,
"profile_use_background_image": true,
"listed_count": 1,
"profile_text_color": "3E4415",
"lang": "en",
"followers_count": 63,
"protected": false,
"notifications": null,
"profile_background_image_url_https": "https://si0.twimg.com/images/themes/theme5/bg.gif",
"profile_background_color": "352726",
"verified": false,
"geo_enabled": false,
"time_zone": "Eastern Time (US & Canada)",
"description": "Science Fiction Writer, sort of. Likes Superheroes, Mole People, Alt. Timelines.",
"default_profile_image": false,
"profile_background_image_url": "http://a0.twimg.com/images/themes/theme5/bg.gif",
"statuses_count": 1048,
"friends_count": 63,
"following": null,
"show_all_inline_media": false,
"screen_name": "MonkiesFist"
},
"in_reply_to_screen_name": null,
"source": "web",
"in_reply_to_status_id": null
},
{
"coordinates": null,
"favorited": false,
"truncated": false,
"created_at": "Fri Sep 21 22:51:18 +0000 2012",
"id_str": "249279667666817024",
"entities": {
"urls": [
],
"hashtags": [
{
"text": "freebandnames",
"indices": [
20,
34
]
}
],
"user_mentions": [
]
},
"in_reply_to_user_id_str": null,
"contributors": null,
"text": "The Foolish Mortals #freebandnames",
"metadata": {
"iso_language_code": "en",
"result_type": "recent"
},
"retweet_count": 0,
"in_reply_to_status_id_str": null,
"id": 249279667666817024,
"geo": null,
"retweeted": false,
"in_reply_to_user_id": null,
"place": null,
"user": {
"profile_sidebar_fill_color": "BFAC83",
"profile_sidebar_border_color": "615A44",
"profile_background_tile": true,
"name": "Marty Elmer",
"profile_image_url": "http://a0.twimg.com/profile_images/1629790393/shrinker_2000_trans_normal.png",
"created_at": "Mon May 04 00:05:00 +0000 2009",
"location": "Wisconsin, USA",
"follow_request_sent": null,
"profile_link_color": "3B2A26",
"is_translator": false,
"id_str": "37539828",
"entities": {
"url": {
"urls": [
{
"expanded_url": null,
"url": "http://www.omnitarian.me",
"indices": [
0,
24
]
}
]
},
"description": {
"urls": [
]
}
},
"default_profile": false,
"contributors_enabled": false,
"favourites_count": 647,
"url": "http://www.omnitarian.me",
"profile_image_url_https": "https://si0.twimg.com/profile_images/1629790393/shrinker_2000_trans_normal.png",
"utc_offset": -21600,
"id": 37539828,
"profile_use_background_image": true,
"listed_count": 52,
"profile_text_color": "000000",
"lang": "en",
"followers_count": 608,
"protected": false,
"notifications": null,
"profile_background_image_url_https": "https://si0.twimg.com/profile_background_images/106455659/rect6056-9.png",
"profile_background_color": "EEE3C4",
"verified": false,
"geo_enabled": false,
"time_zone": "Central Time (US & Canada)",
"description": "Cartoonist, Illustrator, and T-Shirt connoisseur",
"default_profile_image": false,
"profile_background_image_url": "http://a0.twimg.com/profile_background_images/106455659/rect6056-9.png",
"statuses_count": 3575,
"friends_count": 249,
"following": null,
"show_all_inline_media": true,
"screen_name": "Omnitarian"
},
"in_reply_to_screen_name": null,
"source": "<a href=\"//twitter.com/download/iphone%5C%22\" rel=\"\\\"nofollow\\\"\">Twitter for iPhone</a>",
"in_reply_to_status_id": null
}
],
"search_metadata": {
"max_id": 250126199840518145,
"since_id": 24012619984051000,
"refresh_url": "?since_id=250126199840518145&q=%23freebandnames&result_type=mixed&include_entities=1",
"next_results": "?max_id=249279667666817023&q=%23freebandnames&count=4&include_entities=1&result_type=mixed",
"count": 4,
"completed_in": 0.035,
"since_id_str": "24012619984051000",
"query": "%23freebandnames",
"max_id_str": "250126199840518145"
}
}

View File

@ -0,0 +1,190 @@
// +build use_ffjson
package benchmark
import (
"testing"
"github.com/pquerna/ffjson/ffjson"
)
func BenchmarkFF_Unmarshal_M(b *testing.B) {
b.SetBytes(int64(len(largeStructText)))
for i := 0; i < b.N; i++ {
var s LargeStruct
err := ffjson.UnmarshalFast(largeStructText, &s)
if err != nil {
b.Error(err)
}
}
}
func BenchmarkFF_Unmarshal_S(b *testing.B) {
for i := 0; i < b.N; i++ {
var s Entities
err := ffjson.UnmarshalFast(smallStructText, &s)
if err != nil {
b.Error(err)
}
}
b.SetBytes(int64(len(smallStructText)))
}
func BenchmarkFF_Marshal_M(b *testing.B) {
var l int64
for i := 0; i < b.N; i++ {
data, err := ffjson.MarshalFast(&largeStructData)
if err != nil {
b.Error(err)
}
l = int64(len(data))
}
b.SetBytes(l)
}
func BenchmarkFF_Marshal_S(b *testing.B) {
var l int64
for i := 0; i < b.N; i++ {
data, err := ffjson.MarshalFast(&smallStructData)
if err != nil {
b.Error(err)
}
l = int64(len(data))
}
b.SetBytes(l)
}
func BenchmarkFF_Marshal_M_Pool(b *testing.B) {
var l int64
for i := 0; i < b.N; i++ {
data, err := ffjson.MarshalFast(&largeStructData)
if err != nil {
b.Error(err)
}
l = int64(len(data))
ffjson.Pool(data)
}
b.SetBytes(l)
}
func BenchmarkFF_Marshal_L(b *testing.B) {
var l int64
for i := 0; i < b.N; i++ {
data, err := ffjson.MarshalFast(&xlStructData)
if err != nil {
b.Error(err)
}
l = int64(len(data))
}
b.SetBytes(l)
}
func BenchmarkFF_Marshal_L_Pool(b *testing.B) {
var l int64
for i := 0; i < b.N; i++ {
data, err := ffjson.MarshalFast(&xlStructData)
if err != nil {
b.Error(err)
}
l = int64(len(data))
ffjson.Pool(data)
}
b.SetBytes(l)
}
func BenchmarkFF_Marshal_L_Pool_Parallel(b *testing.B) {
var l int64
for i := 0; i < b.N; i++ {
data, err := ffjson.MarshalFast(&xlStructData)
if err != nil {
b.Error(err)
}
l = int64(len(data))
ffjson.Pool(data)
}
b.SetBytes(l)
}
func BenchmarkFF_Marshal_M_Pool_Parallel(b *testing.B) {
var l int64
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
data, err := ffjson.MarshalFast(&largeStructData)
if err != nil {
b.Error(err)
}
l = int64(len(data))
ffjson.Pool(data)
}
})
b.SetBytes(l)
}
func BenchmarkFF_Marshal_S_Pool(b *testing.B) {
var l int64
for i := 0; i < b.N; i++ {
data, err := ffjson.MarshalFast(&smallStructData)
if err != nil {
b.Error(err)
}
l = int64(len(data))
ffjson.Pool(data)
}
b.SetBytes(l)
}
func BenchmarkFF_Marshal_S_Pool_Parallel(b *testing.B) {
var l int64
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
data, err := ffjson.MarshalFast(&smallStructData)
if err != nil {
b.Error(err)
}
l = int64(len(data))
ffjson.Pool(data)
}
})
b.SetBytes(l)
}
func BenchmarkFF_Marshal_S_Parallel(b *testing.B) {
var l int64
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
data, err := ffjson.MarshalFast(&smallStructData)
if err != nil {
b.Error(err)
}
l = int64(len(data))
}
})
b.SetBytes(l)
}
func BenchmarkFF_Marshal_M_Parallel(b *testing.B) {
var l int64
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
data, err := ffjson.MarshalFast(&largeStructData)
if err != nil {
b.Error(err)
}
l = int64(len(data))
}
})
b.SetBytes(l)
}
func BenchmarkFF_Marshal_L_Parallel(b *testing.B) {
var l int64
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
data, err := ffjson.MarshalFast(&xlStructData)
if err != nil {
b.Error(err)
}
l = int64(len(data))
}
})
b.SetBytes(l)
}

View File

@ -0,0 +1,119 @@
// +build use_jsoniter
package benchmark
import (
"testing"
jsoniter "github.com/json-iterator/go"
)
func BenchmarkJI_Unmarshal_M(b *testing.B) {
b.SetBytes(int64(len(largeStructText)))
for i := 0; i < b.N; i++ {
var s LargeStruct
err := jsoniter.Unmarshal(largeStructText, &s)
if err != nil {
b.Error(err)
}
}
}
func BenchmarkJI_Unmarshal_S(b *testing.B) {
for i := 0; i < b.N; i++ {
var s Entities
err := jsoniter.Unmarshal(smallStructText, &s)
if err != nil {
b.Error(err)
}
}
b.SetBytes(int64(len(smallStructText)))
}
func BenchmarkJI_Marshal_M(b *testing.B) {
var l int64
for i := 0; i < b.N; i++ {
data, err := jsoniter.Marshal(&largeStructData)
if err != nil {
b.Error(err)
}
l = int64(len(data))
}
b.SetBytes(l)
}
func BenchmarkJI_Marshal_L(b *testing.B) {
var l int64
for i := 0; i < b.N; i++ {
data, err := jsoniter.Marshal(&xlStructData)
if err != nil {
b.Error(err)
}
l = int64(len(data))
}
b.SetBytes(l)
}
func BenchmarkJI_Marshal_M_Parallel(b *testing.B) {
var l int64
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
data, err := jsoniter.Marshal(&largeStructData)
if err != nil {
b.Error(err)
}
l = int64(len(data))
}
})
b.SetBytes(l)
}
func BenchmarkJI_Marshal_L_Parallel(b *testing.B) {
var l int64
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
data, err := jsoniter.Marshal(&xlStructData)
if err != nil {
b.Error(err)
}
l = int64(len(data))
}
})
b.SetBytes(l)
}
func BenchmarkJI_Marshal_S(b *testing.B) {
var l int64
for i := 0; i < b.N; i++ {
data, err := jsoniter.Marshal(&smallStructData)
if err != nil {
b.Error(err)
}
l = int64(len(data))
}
b.SetBytes(l)
}
func BenchmarkJI_Marshal_S_Parallel(b *testing.B) {
var l int64
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
data, err := jsoniter.Marshal(&smallStructData)
if err != nil {
b.Error(err)
}
l = int64(len(data))
}
})
b.SetBytes(l)
}
func BenchmarkJI_Marshal_M_ToWriter(b *testing.B) {
enc := jsoniter.NewEncoder(&DummyWriter{})
for i := 0; i < b.N; i++ {
err := enc.Encode(&largeStructData)
if err != nil {
b.Error(err)
}
}
}

7
vendor/github.com/mailru/easyjson/benchmark/ujson.sh generated vendored Executable file
View File

@ -0,0 +1,7 @@
#/bin/bash
echo -n "Python ujson module, DECODE: "
python -m timeit -s "import ujson; data = open('`dirname $0`/example.json', 'r').read()" 'ujson.loads(data)'
echo -n "Python ujson module, ENCODE: "
python -m timeit -s "import ujson; data = open('`dirname $0`/example.json', 'r').read(); obj = ujson.loads(data)" 'ujson.dumps(obj)'