Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi: Move each serializer into its own package #141

Merged
merged 31 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0dfde02
baseline: Move to own pkg
matheusd May 24, 2024
72eebb8
mus: Move to own pkg
matheusd May 24, 2024
1c30e21
benc: Move to own pkg
matheusd May 24, 2024
e2d3708
fastjson: Move to own pkg
matheusd May 24, 2024
25aba35
bebop_wellquite: Move to own pkg
matheusd May 24, 2024
f692652
bebop200sc: Move to own pkg
matheusd May 24, 2024
c8e89d7
ssz: Move to own pkg
matheusd May 24, 2024
f85edb0
shamaton: Move to own pkg
matheusd May 24, 2024
676b0bd
ikea: Move to own pkg
matheusd May 24, 2024
a26ae55
avro: Move to own pkg
matheusd May 24, 2024
4f46ba1
xdr_calmh: Move to own pkg
matheusd May 24, 2024
3cadeb8
gencode: Move to own pkg
matheusd May 24, 2024
dce36ae
colfer: Move to own pkg
matheusd May 24, 2024
a162402
gogo: Move to own pkg
matheusd May 24, 2024
64bbdc6
pulsar: Move to own pkg
matheusd May 24, 2024
c45bc8e
protobuf_dedis: Move to own pkg
matheusd May 24, 2024
c4b4013
hprose: Move to own pkg
matheusd May 24, 2024
212bd72
capnproto: Move to own pkg
matheusd May 24, 2024
1710334
flatbuffers: Move to own pkg
matheusd May 24, 2024
a001518
binary: Move to own pkg
matheusd May 24, 2024
419a38e
sereal: Move to own pkg
matheusd May 24, 2024
e97049a
ugorji: Move to own pkg
matheusd May 24, 2024
c76bab3
xdr_davecgh: Move to own pkg
matheusd May 24, 2024
1158df5
stdlib: Move to own pkg
matheusd May 24, 2024
9fd6a22
bson: Move to own pkg
matheusd May 24, 2024
ae38e36
json: Move to own pkg
matheusd May 24, 2024
d573598
msgpack_vmihailenco: Move to own pkg
matheusd May 24, 2024
396fc97
msgpack_tinylib: Move to own pkg
matheusd May 24, 2024
92ed94b
gotiny: Move to own pkg
matheusd May 24, 2024
989e069
fixup! colfer: Move to own pkg
matheusd May 24, 2024
0da87d4
main: Remove unnecessary cruft
matheusd May 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions adapter_interface.go

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package goserbench
package avro

import (
"bytes"
Expand Down Expand Up @@ -57,7 +57,7 @@ var avroSchemaJSON = `
}
`

func NewAvroA() Serializer {
func NewAvroA() goserbench.Serializer {
rec, err := goavro.NewRecord(goavro.RecordSchema(avroSchemaJSON))
if err != nil {
panic(err)
Expand Down Expand Up @@ -139,7 +139,7 @@ func avroUnmarshal(d []byte, o interface{}, unmarshalFunc func([]byte) (interfac
return nil
}

func NewAvro2Txt() Serializer {
func NewAvro2Txt() goserbench.Serializer {
codec, err := goavro2.NewCodec(avroSchemaJSON)
if err != nil {
panic(err)
Expand All @@ -159,7 +159,7 @@ func (a *Avro2Txt) String() string {
return "GoAvro2Text"
}

func NewAvro2Bin() Serializer {
func NewAvro2Bin() goserbench.Serializer {
codec, err := goavro2.NewCodec(avroSchemaJSON)
if err != nil {
panic(err)
Expand Down
4 changes: 2 additions & 2 deletions baseline.go → internal/serializers/baseline/baseline.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package goserbench
package baseline

import (
"encoding/binary"
Expand Down Expand Up @@ -61,6 +61,6 @@ func (b *BaselineSerializer) Unmarshal(d []byte, o interface{}) error {
return nil
}

func NewBaselineSerializer() Serializer {
func NewBaselineSerializer() goserbench.Serializer {
return &BaselineSerializer{b: make([]byte, 47)}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package goserbench
package bebop200sc

import (
"time"
Expand Down Expand Up @@ -49,6 +49,6 @@ func (s *Bebop200ScSerializer) ForceUTC() bool {
return true
}

func NewBebop200ScSerializer() Serializer {
func NewBebop200ScSerializer() goserbench.Serializer {
return &Bebop200ScSerializer{buf: make([]byte, 1024)}
}
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package goserbench
package bebopwellquite

import (
"time"
Expand Down Expand Up @@ -44,7 +44,7 @@ func (s *BebopWellquiteSerializer) TimePrecision() time.Duration {
return 100 * time.Nanosecond
}

func NewBebopWellquiteSerializer() Serializer {
func NewBebopWellquiteSerializer() goserbench.Serializer {
return &BebopWellquiteSerializer{
buf: make([]byte, 1024),
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions benc.go → internal/serializers/benc/benc.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package goserbench
package benc

import (
"time"
Expand Down Expand Up @@ -61,7 +61,7 @@ func (s BENCSerializer) Unmarshal(bs []byte, o interface{}) (err error) {
return
}

func NewBENCSerializer() Serializer {
func NewBENCSerializer() goserbench.Serializer {
return BENCSerializer{}
}

Expand Down Expand Up @@ -118,6 +118,6 @@ func (s BENCUnsafeSerializer) Unmarshal(bs []byte, o interface{}) (err error) {
return
}

func NewBENCUnsafeSerializer() Serializer {
func NewBENCUnsafeSerializer() goserbench.Serializer {
return BENCUnsafeSerializer{}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package goserbench
package binaryalecthomas

import "github.com/alecthomas/binary"
import (
"github.com/alecthomas/binary"
"github.com/alecthomas/go_serialization_benchmarks/goserbench"
)

type BinarySerializer struct{}

Expand All @@ -12,6 +15,6 @@ func (b BinarySerializer) Unmarshal(d []byte, o interface{}) error {
return binary.Unmarshal(d, o)
}

func NewBinarySerializer() Serializer {
func NewBinarySerializer() goserbench.Serializer {
return BinarySerializer{}
}
5 changes: 3 additions & 2 deletions bson.go → internal/serializers/bson/bson.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package goserbench
package bson

import (
"time"

"github.com/alecthomas/go_serialization_benchmarks/goserbench"
"gopkg.in/mgo.v2/bson"
)

Expand All @@ -20,6 +21,6 @@ func (m BsonSerializer) Unmarshal(d []byte, o interface{}) error {
return bson.Unmarshal(d, o)
}

func NewBsonSerializer() Serializer {
func NewBsonSerializer() goserbench.Serializer {
return BsonSerializer{}
}
4 changes: 2 additions & 2 deletions capnproto.go → internal/serializers/capnproto/capnproto.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package goserbench
package capnproto

import (
"bytes"
Expand Down Expand Up @@ -41,6 +41,6 @@ func (x CapNProtoSerializer) Unmarshal(d []byte, i interface{}) error {
return nil
}

func NewCapNProtoSerializer() Serializer {
func NewCapNProtoSerializer() goserbench.Serializer {
return CapNProtoSerializer{}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Go = import "/github.com/glycerine/go-capnproto/go.capnp";
$Go.package("goserbench");
$Go.import("github.com/alecthomas/go_serialization_benchmarks");
$Go.package("capnproto");
$Go.import("github.com/alecthomas/go_serialization_benchmarks/internal/capnproto");

@0x99ea7c74456111bd;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package goserbench
package capnproto

// AUTO GENERATED - DO NOT EDIT

Expand Down
4 changes: 2 additions & 2 deletions colfer.go → internal/serializers/colfer/colfer.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package goserbench
package colfer

import "github.com/alecthomas/go_serialization_benchmarks/goserbench"

Expand Down Expand Up @@ -43,6 +43,6 @@ func (s *ColferSerializer) Unmarshal(bs []byte, o interface{}) (err error) {
return
}

func NewColferSerializer() Serializer {
func NewColferSerializer() goserbench.Serializer {
return &ColferSerializer{}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
4 changes: 2 additions & 2 deletions easyjson.go → internal/serializers/easyjson/easyjson.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package goserbench
package easyjson

import (
"github.com/alecthomas/go_serialization_benchmarks/goserbench"
Expand Down Expand Up @@ -38,6 +38,6 @@ func (m EasyJSONSerializer) Unmarshal(d []byte, o interface{}) error {
return nil
}

func NewEasyJSONSerializer() Serializer {
func NewEasyJSONSerializer() goserbench.Serializer {
return EasyJSONSerializer{}
}
5 changes: 4 additions & 1 deletion structdef.go → internal/serializers/easyjson/structdef.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package goserbench
package easyjson

import (
"time"
)

// This is a copy of the goserbench.SmallStruct because easyjson code generation
// adds methods to it.

//easyjson:json
type A struct {
Name string
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions fastjson.go → internal/serializers/fastjson/fastjson.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package goserbench
package fastjson

import (
"time"
Expand Down Expand Up @@ -46,7 +46,7 @@ func (s *FastJSONSerializer) Unmarshal(bs []byte, o interface{}) (err error) {
return nil
}

func NewFastJSONSerializer() Serializer {
func NewFastJSONSerializer() goserbench.Serializer {
var arena fastjson.Arena
return &FastJSONSerializer{
object: arena.NewObject(),
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package goserbench
package flatbuffers

import (
"time"
Expand Down Expand Up @@ -44,6 +44,6 @@ func (s *FlatBufferSerializer) Unmarshal(d []byte, i interface{}) error {
return nil
}

func NewFlatBuffersSerializer() Serializer {
func NewFlatBuffersSerializer() goserbench.Serializer {
return &FlatBufferSerializer{flatbuffers.NewBuilder(0)}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package goserbench
package gencode

import (
"io"
Expand Down
6 changes: 3 additions & 3 deletions gencode.go → internal/serializers/gencode/gencode.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package goserbench
package gencode

import (
"time"
Expand Down Expand Up @@ -40,7 +40,7 @@ func (s *GencodeSerializer) Unmarshal(bs []byte, o interface{}) (err error) {
return
}

func NewGencodeSerializer() Serializer {
func NewGencodeSerializer() goserbench.Serializer {
return &GencodeSerializer{buf: make([]byte, 0, 1024)}
}

Expand Down Expand Up @@ -78,6 +78,6 @@ func (s *GencodeUnsafeSerializer) Unmarshal(bs []byte, o interface{}) (err error
return
}

func NewGencodeUnsafeSerializer() Serializer {
func NewGencodeUnsafeSerializer() goserbench.Serializer {
return &GencodeUnsafeSerializer{buf: make([]byte, 0, 1024)}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package goserbench
package gencode

import (
"io"
Expand Down
6 changes: 3 additions & 3 deletions gogoprotobuf.go → internal/serializers/gogo/gogoprotobuf.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package goserbench
package gogo

import (
"bytes"
Expand Down Expand Up @@ -51,14 +51,14 @@ func (s *GogoProtoSerializer) Unmarshal(bs []byte, o interface{}) (err error) {
return
}

func NewGogoProtoSerializer() Serializer {
func NewGogoProtoSerializer() goserbench.Serializer {
return &GogoProtoSerializer{
marshaller: proto.Marshal,
unmarshaller: proto.Unmarshal,
}
}

func NewGogoJsonSerializer() Serializer {
func NewGogoJsonSerializer() goserbench.Serializer {
marshaller := &jsonpb.Marshaler{}
buf := bytes.NewBuffer(make([]byte, 0, 1024))

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ syntax = "proto2";

package goserbench;

option go_package = "github.com/alecthomas/go_serialization_benchmarks;goserbench";
option go_package = "github.com/alecthomas/go_serialization_benchmarks/internal/gogo;gogo";

import "github.com/gogo/protobuf/gogoproto/gogo.proto";

Expand Down
7 changes: 4 additions & 3 deletions gotiny.go → internal/serializers/gotiny/gotiny.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package goserbench
package gotiny

import (
reflect "reflect"

"github.com/alecthomas/go_serialization_benchmarks/goserbench"
"github.com/cybriq/gotiny"
)

Expand All @@ -19,8 +20,8 @@ func (g GotinySerializer) Unmarshal(d []byte, o interface{}) error {
return nil
}

func NewGotinySerializer() Serializer {
ot := reflect.TypeOf(A{})
func NewGotinySerializer() goserbench.Serializer {
ot := reflect.TypeOf(goserbench.SmallStruct{})
return GotinySerializer{
dec: gotiny.NewDecoderWithType(ot),
}
Expand Down
4 changes: 2 additions & 2 deletions hprose.go → internal/serializers/hprose/hprose.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package goserbench
package hprose

import (
"bytes"
Expand Down Expand Up @@ -54,7 +54,7 @@ func (s *HproseSerializer) Unmarshal(d []byte, i interface{}) (err error) {
return err
}

func NewHproseSerializer() Serializer {
func NewHproseSerializer() goserbench.Serializer {
buf := new(bytes.Buffer)
reader := hprose.NewReader(buf, true)
bufw := new(bytes.Buffer)
Expand Down
Loading