Skip to content

Commit

Permalink
Remove mus_reuse, mus_unsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
ymz-ncnk committed Jun 20, 2024
1 parent 348ebbe commit b82a42e
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 181 deletions.
16 changes: 0 additions & 16 deletions benchmarks.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,22 +446,6 @@ var benchmarkCases = []BenchmarkCase{

TimeSupport: TSNoSupport,
APIKind: AKManual,
}, {
Name: "mus/reuse",
URL: "github.com/mus-format/mus-go",
New: mus.NewMUSReuseSerializer,

BufferReuseMarshal: true,
TimeSupport: TSNoSupport,
APIKind: AKManual,
}, {
Name: "mus/unsafe",
URL: "github.com/mus-format/mus-go",
New: mus.NewMUSUnsafeSerializer,

UnsafeStringUnmarshal: true,
TimeSupport: TSNoSupport,
APIKind: AKManual,
}, {
Name: "mus/unsafe_reuse",
URL: "github.com/mus-format/mus-go",
Expand Down
121 changes: 0 additions & 121 deletions internal/serializers/mus/mus.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,127 +73,6 @@ func NewMUSSerializer() goserbench.Serializer {
return MUSSerializer{}
}

type MUSReuseSerializer struct {
buf []byte
}

func (s MUSReuseSerializer) Marshal(o interface{}) ([]byte, error) {
v := o.(*goserbench.SmallStruct)
n := ord.MarshalString(v.Name, s.buf)
n += raw.MarshalInt64(v.BirthDay.UnixNano(), s.buf[n:])
n += ord.MarshalString(v.Phone, s.buf[n:])
n += varint.MarshalInt32(int32(v.Siblings), s.buf[n:])
n += ord.MarshalBool(v.Spouse, s.buf[n:])
n += raw.MarshalFloat64(v.Money, s.buf[n:])
return s.buf[:n], nil
}

func (s MUSReuseSerializer) Unmarshal(bs []byte, o interface{}) (err error) {
v := o.(*goserbench.SmallStruct)
var n int
v.Name, n, err = ord.UnmarshalString(bs)
if err != nil {
return
}
var (
n1 int
birthDay64 int64
)
birthDay64, n1, err = raw.UnmarshalInt64(bs[n:])
n += n1
if err != nil {
return
}
v.BirthDay = time.Unix(0, birthDay64)
v.Phone, n1, err = ord.UnmarshalString(bs[n:])
n += n1
if err != nil {
return
}
var siblings32 int32
siblings32, n1, err = varint.UnmarshalInt32(bs[n:])
n += n1
if err != nil {
return
}
v.Siblings = int(siblings32)
v.Spouse, n1, err = ord.UnmarshalBool(bs[n:])
n += n1
if err != nil {
return
}
v.Money, n1, err = raw.UnmarshalFloat64(bs[n:])
n += n1
return
}

func NewMUSReuseSerializer() goserbench.Serializer {
return MUSReuseSerializer{buf: make([]byte, 1024)}
}

type MUSUnsafeSerializer struct{}

func (s MUSUnsafeSerializer) Marshal(o interface{}) ([]byte, error) {
v := o.(*goserbench.SmallStruct)
n := unsafe.SizeString(v.Name)
n += unsafe.SizeInt64(v.BirthDay.UnixNano())
n += unsafe.SizeString(v.Phone)
n += unsafe.SizeInt32(int32(v.Siblings))
n += unsafe.SizeBool(v.Spouse)
n += unsafe.SizeFloat64(v.Money)
buf := make([]byte, n)
n = unsafe.MarshalString(v.Name, buf)
n += unsafe.MarshalInt64(v.BirthDay.UnixNano(), buf[n:])
n += unsafe.MarshalString(v.Phone, buf[n:])
n += unsafe.MarshalInt32(int32(v.Siblings), buf[n:])
n += unsafe.MarshalBool(v.Spouse, buf[n:])
unsafe.MarshalFloat64(v.Money, buf[n:])
return buf, nil
}

func (s MUSUnsafeSerializer) Unmarshal(bs []byte, o interface{}) (err error) {
v := o.(*goserbench.SmallStruct)
var n int
v.Name, n, err = unsafe.UnmarshalString(bs)
if err != nil {
return
}
var (
n1 int
birthDay64 int64
)
birthDay64, n1, err = unsafe.UnmarshalInt64(bs[n:])
n += n1
if err != nil {
return
}
v.BirthDay = time.Unix(0, birthDay64)
v.Phone, n1, err = unsafe.UnmarshalString(bs[n:])
n += n1
if err != nil {
return
}
var siblings32 int32
siblings32, n1, err = unsafe.UnmarshalInt32(bs[n:])
n += n1
if err != nil {
return
}
v.Siblings = int(siblings32)
v.Spouse, n1, err = unsafe.UnmarshalBool(bs[n:])
n += n1
if err != nil {
return
}
v.Money, n1, err = unsafe.UnmarshalFloat64(bs[n:])
n += n1
return
}

func NewMUSUnsafeSerializer() goserbench.Serializer {
return MUSUnsafeSerializer{}
}

type MUSUnsafeReuseSerializer struct {
buf []byte
}
Expand Down
44 changes: 0 additions & 44 deletions report/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -967,50 +967,6 @@ var data = [
"url": "github.com/mus-format/mus-go",
"notes": ""
},
{
"name": "mus/reuse",
"marshal_iter_count": 372270032,
"unmarshal_iter_count": 65966484,
"total_iter_count": 438236516,
"unsafe_string_unmarshal": false,
"buffer_reuse_marshal": true,
"marshal_ns_op": 33,
"unmarshal_ns_op": 174,
"total_ns_op": 207,
"serialization_size": 46,
"marshal_alloc_bytes": 0,
"unmarshal_alloc_bytes": 32,
"total_alloc_bytes": 32,
"marshal_allocs": 0,
"unmarshal_allocs": 2,
"total_allocs": 2,
"time_support": "no",
"api_kind": "manual",
"url": "github.com/mus-format/mus-go",
"notes": ""
},
{
"name": "mus/unsafe",
"marshal_iter_count": 88965540,
"unmarshal_iter_count": 407212309,
"total_iter_count": 496177849,
"unsafe_string_unmarshal": true,
"buffer_reuse_marshal": false,
"marshal_ns_op": 132,
"unmarshal_ns_op": 30,
"total_ns_op": 162,
"serialization_size": 49,
"marshal_alloc_bytes": 64,
"unmarshal_alloc_bytes": 0,
"total_alloc_bytes": 64,
"marshal_allocs": 1,
"unmarshal_allocs": 0,
"total_allocs": 1,
"time_support": "no",
"api_kind": "manual",
"url": "github.com/mus-format/mus-go",
"notes": ""
},
{
"name": "mus/unsafe_reuse",
"marshal_iter_count": 436090794,
Expand Down

0 comments on commit b82a42e

Please sign in to comment.