mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-24 10:11:48 +00:00
.
This commit is contained in:
@ -108,38 +108,6 @@ func BenchmarkTestGob(b *testing.B) {
|
||||
func BenchmarkTestMsgPack(b *testing.B) {
|
||||
b.StopTimer()
|
||||
|
||||
var mh codec.MsgpackHandle
|
||||
handle := &mh
|
||||
|
||||
h := &Header{
|
||||
Name: "Header",
|
||||
Height: 123,
|
||||
Fees: 123,
|
||||
Time: 123,
|
||||
PrevHash: []byte("prevhash"),
|
||||
ValidationHash: []byte("validationhash"),
|
||||
DataHash: []byte("datahash"),
|
||||
}
|
||||
h2 := &Header{}
|
||||
|
||||
buf := bytes.NewBuffer(nil)
|
||||
enc := codec.NewEncoder(buf, handle)
|
||||
dec := codec.NewDecoder(buf, handle)
|
||||
|
||||
b.StartTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
buf.Reset()
|
||||
enc.Encode(h)
|
||||
dec.Decode(h2)
|
||||
if h2.Name != "Header" {
|
||||
b.Fatalf("wrong name")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkTestMsgPack2(b *testing.B) {
|
||||
b.StopTimer()
|
||||
|
||||
h := &Header{
|
||||
Name: "Header",
|
||||
Height: 123,
|
||||
@ -165,3 +133,34 @@ func BenchmarkTestMsgPack2(b *testing.B) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkTestMsgPack2(b *testing.B) {
|
||||
b.StopTimer()
|
||||
|
||||
h := &Header{
|
||||
Name: "Header",
|
||||
Height: 123,
|
||||
Fees: 123,
|
||||
Time: 123,
|
||||
PrevHash: []byte("prevhash"),
|
||||
ValidationHash: []byte("validationhash"),
|
||||
DataHash: []byte("datahash"),
|
||||
}
|
||||
h2 := &Header{}
|
||||
var mh codec.MsgpackHandle
|
||||
handle := &mh
|
||||
|
||||
buf := bytes.NewBuffer(nil)
|
||||
enc := codec.NewEncoder(buf, handle)
|
||||
dec := codec.NewDecoder(buf, handle)
|
||||
|
||||
b.StartTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
buf.Reset()
|
||||
enc.Encode(h)
|
||||
dec.Decode(h2)
|
||||
if h2.Name != "Header" {
|
||||
b.Fatalf("wrong name")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user