31 lines
530 B
Go
31 lines
530 B
Go
package dinetrpc
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"github.com/gogo/protobuf/proto"
|
|
"github.com/vmihailenco/msgpack"
|
|
)
|
|
|
|
func BenchmarkJSONMarshal(b *testing.B) {
|
|
r := newTestMsg()
|
|
for i := 0; i < b.N; i++ {
|
|
_, _ = json.Marshal(r.RequestMsg)
|
|
}
|
|
}
|
|
|
|
func BenchmarkMsgPackMarshal(b *testing.B) {
|
|
r := newTestMsg()
|
|
for i := 0; i < b.N; i++ {
|
|
_, _ = msgpack.Marshal(r.RequestMsg)
|
|
}
|
|
}
|
|
|
|
func BenchmarkProtobufMarshal(b *testing.B) {
|
|
r := newTestMsg()
|
|
for i := 0; i < b.N; i++ {
|
|
_, _ = proto.Marshal(r.RequestMsg)
|
|
}
|
|
}
|