mirror of
https://github.com/libp2p/go-libp2p-peerstore.git
synced 2025-02-20 08:30:27 +08:00
Introduces custom types in protobuf to serde directly into multiaddrs and peer IDs. Simplify purge by ordering addrs by expiry. In general, getting this readier for merge.
128 lines
3.3 KiB
Go
128 lines
3.3 KiB
Go
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
|
// source: pstore.proto
|
|
|
|
package pstore_pb
|
|
|
|
import testing "testing"
|
|
import math_rand "math/rand"
|
|
import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
|
|
import proto "github.com/gogo/protobuf/proto"
|
|
import fmt "fmt"
|
|
import math "math"
|
|
import _ "github.com/gogo/protobuf/gogoproto"
|
|
|
|
// Reference imports to suppress errors if they are not otherwise used.
|
|
var _ = proto.Marshal
|
|
var _ = fmt.Errorf
|
|
var _ = math.Inf
|
|
|
|
func BenchmarkAddrBookRecordProtoMarshal(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
pops := make([]*AddrBookRecord, 10000)
|
|
for i := 0; i < 10000; i++ {
|
|
pops[i] = NewPopulatedAddrBookRecord(popr, false)
|
|
}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000])
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
total += len(dAtA)
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func BenchmarkAddrBookRecordProtoUnmarshal(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
datas := make([][]byte, 10000)
|
|
for i := 0; i < 10000; i++ {
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedAddrBookRecord(popr, false))
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
datas[i] = dAtA
|
|
}
|
|
msg := &AddrBookRecord{}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
total += len(datas[i%10000])
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func BenchmarkAddrBookRecord_AddrEntryProtoMarshal(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
pops := make([]*AddrBookRecord_AddrEntry, 10000)
|
|
for i := 0; i < 10000; i++ {
|
|
pops[i] = NewPopulatedAddrBookRecord_AddrEntry(popr, false)
|
|
}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000])
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
total += len(dAtA)
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func BenchmarkAddrBookRecord_AddrEntryProtoUnmarshal(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
datas := make([][]byte, 10000)
|
|
for i := 0; i < 10000; i++ {
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedAddrBookRecord_AddrEntry(popr, false))
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
datas[i] = dAtA
|
|
}
|
|
msg := &AddrBookRecord_AddrEntry{}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
total += len(datas[i%10000])
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func BenchmarkAddrBookRecordSize(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
pops := make([]*AddrBookRecord, 1000)
|
|
for i := 0; i < 1000; i++ {
|
|
pops[i] = NewPopulatedAddrBookRecord(popr, false)
|
|
}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
total += pops[i%1000].Size()
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func BenchmarkAddrBookRecord_AddrEntrySize(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
pops := make([]*AddrBookRecord_AddrEntry, 1000)
|
|
for i := 0; i < 1000; i++ {
|
|
pops[i] = NewPopulatedAddrBookRecord_AddrEntry(popr, false)
|
|
}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
total += pops[i%1000].Size()
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
//These tests are generated by github.com/gogo/protobuf/plugin/testgen
|