Skip to content

Commit

Permalink
generate csv files for test results
Browse files Browse the repository at this point in the history
  • Loading branch information
smallnest committed Dec 4, 2019
1 parent 360a1c7 commit 00668f9
Show file tree
Hide file tree
Showing 11 changed files with 261 additions and 2 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ require (
github.com/niubaoshu/gotiny v0.0.3
github.com/philhofer/fwd v1.0.0 // indirect
github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7
github.com/sbinet/go-gnuplot v0.0.0-20130514120836-9167d8eb1ac4
github.com/segmentio/encoding v0.1.0
github.com/tidwall/gjson v1.3.2
github.com/tinylib/msgp v1.1.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7 h1:xoIK0ctDddBMnc74udxJYBqlo9Ylnsp1waqjLsnef20=
github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7/go.mod h1:YARuvh7BUWHNhzDq2OM5tzR2RiCcN2D7sapiKyCel/M=
github.com/sbinet/go-gnuplot v0.0.0-20130514120836-9167d8eb1ac4 h1:DjPYuV8FWDg57bkdJ2DQUB6PMQJUapXdJ1uCvPC7XT0=
github.com/sbinet/go-gnuplot v0.0.0-20130514120836-9167d8eb1ac4/go.mod h1:cBjaN6xLFdcYFeCkvNXnUCPPeHA23BR6Yg6liSwsLjE=
github.com/segmentio/encoding v0.1.0 h1:V/FrZFA2Fm4Hpk3JdA+3JWN6fJnp15dZOnB+CI3Wcbw=
github.com/segmentio/encoding v0.1.0/go.mod h1:RWhr02uzMB9gQC1x+MfYxedtmBibb9cZ6Vv9VxRSSbw=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down
2 changes: 1 addition & 1 deletion gosercomp_data.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gosercomp
package main

import (
"github.com/golang/protobuf/proto"
Expand Down
2 changes: 1 addition & 1 deletion gosercomp_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gosercomp
package main

import (
"bytes"
Expand Down
30 changes: 30 additions & 0 deletions marshal.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-- found gnuplot command: /usr/local/bin/gnuplot
goos: darwin
goarch: amd64
pkg: github.com/smallnest/gosercomp
BenchmarkMarshalByJson-4 1850058 647 ns/op 65.0 marshaledBytes
BenchmarkMarshalByXml-4 308764 3997 ns/op 137 marshaledBytes
BenchmarkMarshalByMsgp-4 10046798 140 ns/op 47.0 marshaledBytes
BenchmarkMarshalByProtoBuf-4 5250182 256 ns/op 36.0 marshaledBytes
BenchmarkMarshalByGogoProtoBuf-4 4894754 257 ns/op 36.0 marshaledBytes
BenchmarkMarshalByThrift-4 1995572 566 ns/op 63.0 marshaledBytes
BenchmarkMarshalByAvro-4 3410665 346 ns/op 32.0 marshaledBytes
BenchmarkMarshalByGencode-4 24767253 51.2 ns/op 34.0 marshaledBytes
BenchmarkMarshalByUgorjiCodecAndCbor-4 1717364 682 ns/op 47.0 marshaledBytes
BenchmarkMarshalByUgorjiCodecAndMsgp-4 1858545 726 ns/op 47.0 marshaledBytes
BenchmarkMarshalByUgorjiCodecAndBinc-4 1894346 583 ns/op 47.0 marshaledBytes
BenchmarkMarshalByUgorjiCodecAndJson-4 1609161 717 ns/op 65.0 marshaledBytes
BenchmarkMarshalByEasyjson-4 4180846 283 ns/op 65.0 marshaledBytes
BenchmarkMarshalByFfjson-4 1293396 946 ns/op 65.0 marshaledBytes
BenchmarkMarshalByJsoniter-4 2346495 511 ns/op 65.0 marshaledBytes
BenchmarkMarshalByGoMemdump-4 272938 5222 ns/op 200 marshaledBytes
BenchmarkMarshalByColfer-4 34834042 39.2 ns/op 35.0 marshaledBytes
BenchmarkMarshalByZebrapack-4 5803422 307 ns/op 109 marshaledBytes
BenchmarkMarshalByGotiny-4 2643406 422 ns/op 32.0 marshaledBytes
BenchmarkMarshalByHprose-4 3216709 372 ns/op 49.0 marshaledBytes
BenchmarkMarshalBySereal-4 501252 2164 ns/op 76.0 marshaledBytes
BenchmarkMarshalByMsgpackV2-4 890499 1371 ns/op 47.0 marshaledBytes
BenchmarkMarshalByRlp-4 2498214 487 ns/op 32.0 marshaledBytes
BenchmarkMarshalBySegmentioJSON-4 1925108 584 ns/op 65.0 marshaledBytes
PASS
ok github.com/smallnest/gosercomp 40.981s
24 changes: 24 additions & 0 deletions marshal_took.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Json,647
Xml,3997
Msgp,140
ProtoBuf,256
GogoProtoBuf,257
Thrift,566
Avro,346
Gencode,0
UgorjiCodecAndCbor,682
UgorjiCodecAndMsgp,726
UgorjiCodecAndBinc,583
UgorjiCodecAndJson,717
Easyjson,283
Ffjson,946
Jsoniter,511
GoMemdump,5222
Colfer,0
Zebrapack,307
Gotiny,422
Hprose,372
Sereal,2164
MsgpackV2,1371
Rlp,487
SegmentioJSON,584
24 changes: 24 additions & 0 deletions marshaledBytes.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Json,65
Xml,137
Msgp,47
ProtoBuf,36
GogoProtoBuf,36
Thrift,63
Avro,32
Gencode,34
UgorjiCodecAndCbor,47
UgorjiCodecAndMsgp,47
UgorjiCodecAndBinc,47
UgorjiCodecAndJson,65
Easyjson,65
Ffjson,65
Jsoniter,65
GoMemdump,200
Colfer,35
Zebrapack,109
Gotiny,32
Hprose,49
Sereal,76
MsgpackV2,47
Rlp,32
SegmentioJSON,65
98 changes: 98 additions & 0 deletions report.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package main

import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)

func main() {
libs, tooks, marshaledBytes := readMarshalLog()
tookFile, _ := os.OpenFile("marshal_took.csv", os.O_CREATE|os.O_RDWR, 0777)
marshaledBytesFile, _ := os.OpenFile("marshaledBytes.csv", os.O_CREATE|os.O_RDWR, 0777)
defer tookFile.Close()
defer marshaledBytesFile.Close()

for i, name := range libs {
tookFile.WriteString(fmt.Sprintf("%s,%d\n", name, tooks[i]))
marshaledBytesFile.WriteString(fmt.Sprintf("%s,%d\n", name, marshaledBytes[i]))
}

libs, tooks = readUnmarshalLog()
tookFile2, _ := os.OpenFile("unmarshal_took.csv", os.O_CREATE|os.O_RDWR, 0777)
defer tookFile2.Close()

for i, name := range libs {
tookFile2.WriteString(fmt.Sprintf("%s,%d\n", name, tooks[i]))
}

}

func readMarshalLog() ([]string, []int, []int) {
file, err := os.Open("marshal.log")
if err != nil {
panic(err)
}
defer file.Close()

var libs []string
var tooks []int
var marshaledBytes []int

scanner := bufio.NewScanner(file)
for scanner.Scan() {
line := scanner.Text()
if strings.HasPrefix(line, "BenchmarkMarshalBy") {
line = strings.TrimPrefix(line, "BenchmarkMarshalBy")
fields := strings.Fields(line)
name := fields[0]
if strings.Index(name, "-") > 0 {
name = name[:strings.Index(name, "-")]
}
libs = append(libs, name)
tooks = append(tooks, s2i(fields[2]))
marshaledBytes = append(marshaledBytes, int(s2f(fields[4])))
}
}

return libs, tooks, marshaledBytes
}

func readUnmarshalLog() ([]string, []int) {
file, err := os.Open("unmarshal.log")
if err != nil {
panic(err)
}
defer file.Close()

var libs []string
var tooks []int
scanner := bufio.NewScanner(file)
for scanner.Scan() {
line := scanner.Text()
if strings.HasPrefix(line, "BenchmarkUnmarshalBy") {
line = strings.TrimPrefix(line, "BenchmarkUnmarshalBy")
fields := strings.Fields(line)
name := fields[0]
if strings.Index(name, "-") > 0 {
name = name[:strings.Index(name, "-")]
}
libs = append(libs, name)
tooks = append(tooks, s2i(fields[2]))
}
}

return libs, tooks
}

func s2i(s string) int {
f, _ := strconv.Atoi(s)
return f
}

func s2f(s string) float64 {
f, _ := strconv.ParseFloat(s, 64)
return f
}
24 changes: 24 additions & 0 deletions took.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Json,647
Xml,3997
Msgp,140
ProtoBuf,256
GogoProtoBuf,257
Thrift,566
Avro,346
Gencode,0
UgorjiCodecAndCbor,682
UgorjiCodecAndMsgp,726
UgorjiCodecAndBinc,583
UgorjiCodecAndJson,717
Easyjson,283
Ffjson,946
Jsoniter,511
GoMemdump,5222
Colfer,0
Zebrapack,307
Gotiny,422
Hprose,372
Sereal,2164
MsgpackV2,1371
Rlp,487
SegmentioJSON,584
31 changes: 31 additions & 0 deletions unmarshal.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
-- found gnuplot command: /usr/local/bin/gnuplot
goos: darwin
goarch: amd64
pkg: github.com/smallnest/gosercomp
BenchmarkUnmarshalByJson-4 474681 2354 ns/op
BenchmarkUnmarshalByXml-4 93476 12787 ns/op
BenchmarkUnmarshalByMsgp-4 5169606 201 ns/op
BenchmarkUnmarshalByProtoBuf-4 2382018 507 ns/op
BenchmarkUnmarshalByGogoProtoBuf-4 2882487 413 ns/op
BenchmarkUnmarshalByThrift-4 1000000 1303 ns/op
BenchmarkUnmarshalByAvro-4 40338 26255 ns/op
BenchmarkUnmarshalByGencode-4 9043816 148 ns/op
BenchmarkUnmarshalByUgorjiCodecAndCbor-4 1339586 884 ns/op
BenchmarkUnmarshalByUgorjiCodecAndMsgp-4 1000000 1319 ns/op
BenchmarkUnmarshalByUgorjiCodecAndBinc-4 867388 1458 ns/op
BenchmarkUnmarshalByUgorjiCodecAndJson-4 1000000 1199 ns/op
BenchmarkUnmarshalByEasyjson-4 1929847 707 ns/op
BenchmarkUnmarshalByFfjson-4 844473 2286 ns/op
BenchmarkUnmarshalByJsoniter-4 1966244 808 ns/op
BenchmarkUnmarshalByGJSON-4 589440 2668 ns/op
BenchmarkUnmarshalByGoMemdump-4 844342 1500 ns/op
BenchmarkUnmarshalByColfer-4 5667135 247 ns/op
BenchmarkUnmarshalByZebrapack-4 3494541 323 ns/op
BenchmarkUnmarshalByGotiny-4 3546631 488 ns/op
BenchmarkUnmarshalByHprose-4 1779548 664 ns/op
BenchmarkUnmarshalBySereal-4 1714032 699 ns/op
BenchmarkUnmarshalByMsgpackv2-4 1000000 1731 ns/op
BenchmarkUnmarshalByRlp-4 1000000 1019 ns/op
BenchmarkUnmarshalBySegmentioJSON-4 1792550 663 ns/op
PASS
ok github.com/smallnest/gosercomp 41.592s
25 changes: 25 additions & 0 deletions unmarshal_took.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Json,2354
Xml,12787
Msgp,201
ProtoBuf,507
GogoProtoBuf,413
Thrift,1303
Avro,26255
Gencode,148
UgorjiCodecAndCbor,884
UgorjiCodecAndMsgp,1319
UgorjiCodecAndBinc,1458
UgorjiCodecAndJson,1199
Easyjson,707
Ffjson,2286
Jsoniter,808
GJSON,2668
GoMemdump,1500
Colfer,247
Zebrapack,323
Gotiny,488
Hprose,664
Sereal,699
Msgpackv2,1731
Rlp,1019
SegmentioJSON,663

0 comments on commit 00668f9

Please sign in to comment.