2020-03-18 19:19:29 -04:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
// Code generated by github.com/tinylib/msgp DO NOT EDIT.
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/tinylib/msgp/msgp"
|
|
|
|
)
|
|
|
|
|
2020-06-12 13:28:21 -04:00
|
|
|
func TestMarshalUnmarshaldataUsageCache(t *testing.T) {
|
|
|
|
v := dataUsageCache{}
|
|
|
|
bts, err := v.MarshalMsg(nil)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
left, err := v.UnmarshalMsg(bts)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if len(left) > 0 {
|
|
|
|
t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
|
|
|
|
}
|
|
|
|
|
|
|
|
left, err = msgp.Skip(bts)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if len(left) > 0 {
|
|
|
|
t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkMarshalMsgdataUsageCache(b *testing.B) {
|
|
|
|
v := dataUsageCache{}
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
v.MarshalMsg(nil)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkAppendMsgdataUsageCache(b *testing.B) {
|
|
|
|
v := dataUsageCache{}
|
|
|
|
bts := make([]byte, 0, v.Msgsize())
|
|
|
|
bts, _ = v.MarshalMsg(bts[0:0])
|
|
|
|
b.SetBytes(int64(len(bts)))
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
bts, _ = v.MarshalMsg(bts[0:0])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkUnmarshaldataUsageCache(b *testing.B) {
|
|
|
|
v := dataUsageCache{}
|
|
|
|
bts, _ := v.MarshalMsg(nil)
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.SetBytes(int64(len(bts)))
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_, err := v.UnmarshalMsg(bts)
|
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestEncodeDecodedataUsageCache(t *testing.T) {
|
|
|
|
v := dataUsageCache{}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
|
|
|
|
m := v.Msgsize()
|
|
|
|
if buf.Len() > m {
|
|
|
|
t.Log("WARNING: TestEncodeDecodedataUsageCache Msgsize() is inaccurate")
|
|
|
|
}
|
|
|
|
|
|
|
|
vn := dataUsageCache{}
|
|
|
|
err := msgp.Decode(&buf, &vn)
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
err = msgp.NewReader(&buf).Skip()
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkEncodedataUsageCache(b *testing.B) {
|
|
|
|
v := dataUsageCache{}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
b.SetBytes(int64(buf.Len()))
|
|
|
|
en := msgp.NewWriter(msgp.Nowhere)
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
v.EncodeMsg(en)
|
|
|
|
}
|
|
|
|
en.Flush()
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkDecodedataUsageCache(b *testing.B) {
|
|
|
|
v := dataUsageCache{}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
b.SetBytes(int64(buf.Len()))
|
|
|
|
rd := msgp.NewEndlessReader(buf.Bytes(), b)
|
|
|
|
dc := msgp.NewReader(rd)
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
err := v.DecodeMsg(dc)
|
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-18 19:19:29 -04:00
|
|
|
func TestMarshalUnmarshaldataUsageCacheInfo(t *testing.T) {
|
|
|
|
v := dataUsageCacheInfo{}
|
|
|
|
bts, err := v.MarshalMsg(nil)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
left, err := v.UnmarshalMsg(bts)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if len(left) > 0 {
|
|
|
|
t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
|
|
|
|
}
|
|
|
|
|
|
|
|
left, err = msgp.Skip(bts)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if len(left) > 0 {
|
|
|
|
t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkMarshalMsgdataUsageCacheInfo(b *testing.B) {
|
|
|
|
v := dataUsageCacheInfo{}
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
v.MarshalMsg(nil)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkAppendMsgdataUsageCacheInfo(b *testing.B) {
|
|
|
|
v := dataUsageCacheInfo{}
|
|
|
|
bts := make([]byte, 0, v.Msgsize())
|
|
|
|
bts, _ = v.MarshalMsg(bts[0:0])
|
|
|
|
b.SetBytes(int64(len(bts)))
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
bts, _ = v.MarshalMsg(bts[0:0])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkUnmarshaldataUsageCacheInfo(b *testing.B) {
|
|
|
|
v := dataUsageCacheInfo{}
|
|
|
|
bts, _ := v.MarshalMsg(nil)
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.SetBytes(int64(len(bts)))
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_, err := v.UnmarshalMsg(bts)
|
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestEncodeDecodedataUsageCacheInfo(t *testing.T) {
|
|
|
|
v := dataUsageCacheInfo{}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
|
|
|
|
m := v.Msgsize()
|
|
|
|
if buf.Len() > m {
|
|
|
|
t.Log("WARNING: TestEncodeDecodedataUsageCacheInfo Msgsize() is inaccurate")
|
|
|
|
}
|
|
|
|
|
|
|
|
vn := dataUsageCacheInfo{}
|
|
|
|
err := msgp.Decode(&buf, &vn)
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
err = msgp.NewReader(&buf).Skip()
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkEncodedataUsageCacheInfo(b *testing.B) {
|
|
|
|
v := dataUsageCacheInfo{}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
b.SetBytes(int64(buf.Len()))
|
|
|
|
en := msgp.NewWriter(msgp.Nowhere)
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
v.EncodeMsg(en)
|
|
|
|
}
|
|
|
|
en.Flush()
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkDecodedataUsageCacheInfo(b *testing.B) {
|
|
|
|
v := dataUsageCacheInfo{}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
b.SetBytes(int64(buf.Len()))
|
|
|
|
rd := msgp.NewEndlessReader(buf.Bytes(), b)
|
|
|
|
dc := msgp.NewReader(rd)
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
err := v.DecodeMsg(dc)
|
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMarshalUnmarshaldataUsageEntry(t *testing.T) {
|
|
|
|
v := dataUsageEntry{}
|
|
|
|
bts, err := v.MarshalMsg(nil)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
left, err := v.UnmarshalMsg(bts)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if len(left) > 0 {
|
|
|
|
t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
|
|
|
|
}
|
|
|
|
|
|
|
|
left, err = msgp.Skip(bts)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if len(left) > 0 {
|
|
|
|
t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkMarshalMsgdataUsageEntry(b *testing.B) {
|
|
|
|
v := dataUsageEntry{}
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
v.MarshalMsg(nil)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkAppendMsgdataUsageEntry(b *testing.B) {
|
|
|
|
v := dataUsageEntry{}
|
|
|
|
bts := make([]byte, 0, v.Msgsize())
|
|
|
|
bts, _ = v.MarshalMsg(bts[0:0])
|
|
|
|
b.SetBytes(int64(len(bts)))
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
bts, _ = v.MarshalMsg(bts[0:0])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkUnmarshaldataUsageEntry(b *testing.B) {
|
|
|
|
v := dataUsageEntry{}
|
|
|
|
bts, _ := v.MarshalMsg(nil)
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.SetBytes(int64(len(bts)))
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_, err := v.UnmarshalMsg(bts)
|
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestEncodeDecodedataUsageEntry(t *testing.T) {
|
|
|
|
v := dataUsageEntry{}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
|
|
|
|
m := v.Msgsize()
|
|
|
|
if buf.Len() > m {
|
|
|
|
t.Log("WARNING: TestEncodeDecodedataUsageEntry Msgsize() is inaccurate")
|
|
|
|
}
|
|
|
|
|
|
|
|
vn := dataUsageEntry{}
|
|
|
|
err := msgp.Decode(&buf, &vn)
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
err = msgp.NewReader(&buf).Skip()
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkEncodedataUsageEntry(b *testing.B) {
|
|
|
|
v := dataUsageEntry{}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
b.SetBytes(int64(buf.Len()))
|
|
|
|
en := msgp.NewWriter(msgp.Nowhere)
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
v.EncodeMsg(en)
|
|
|
|
}
|
|
|
|
en.Flush()
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkDecodedataUsageEntry(b *testing.B) {
|
|
|
|
v := dataUsageEntry{}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
b.SetBytes(int64(buf.Len()))
|
|
|
|
rd := msgp.NewEndlessReader(buf.Bytes(), b)
|
|
|
|
dc := msgp.NewReader(rd)
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
err := v.DecodeMsg(dc)
|
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-18 16:31:35 -04:00
|
|
|
func TestMarshalUnmarshaldataUsageEntryV5(t *testing.T) {
|
|
|
|
v := dataUsageEntryV5{}
|
|
|
|
bts, err := v.MarshalMsg(nil)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
left, err := v.UnmarshalMsg(bts)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if len(left) > 0 {
|
|
|
|
t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
|
|
|
|
}
|
|
|
|
|
|
|
|
left, err = msgp.Skip(bts)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if len(left) > 0 {
|
|
|
|
t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkMarshalMsgdataUsageEntryV5(b *testing.B) {
|
|
|
|
v := dataUsageEntryV5{}
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
v.MarshalMsg(nil)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkAppendMsgdataUsageEntryV5(b *testing.B) {
|
|
|
|
v := dataUsageEntryV5{}
|
|
|
|
bts := make([]byte, 0, v.Msgsize())
|
|
|
|
bts, _ = v.MarshalMsg(bts[0:0])
|
|
|
|
b.SetBytes(int64(len(bts)))
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
bts, _ = v.MarshalMsg(bts[0:0])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkUnmarshaldataUsageEntryV5(b *testing.B) {
|
|
|
|
v := dataUsageEntryV5{}
|
|
|
|
bts, _ := v.MarshalMsg(nil)
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.SetBytes(int64(len(bts)))
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_, err := v.UnmarshalMsg(bts)
|
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestEncodeDecodedataUsageEntryV5(t *testing.T) {
|
|
|
|
v := dataUsageEntryV5{}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
|
|
|
|
m := v.Msgsize()
|
|
|
|
if buf.Len() > m {
|
|
|
|
t.Log("WARNING: TestEncodeDecodedataUsageEntryV5 Msgsize() is inaccurate")
|
|
|
|
}
|
|
|
|
|
|
|
|
vn := dataUsageEntryV5{}
|
|
|
|
err := msgp.Decode(&buf, &vn)
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
err = msgp.NewReader(&buf).Skip()
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkEncodedataUsageEntryV5(b *testing.B) {
|
|
|
|
v := dataUsageEntryV5{}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
b.SetBytes(int64(buf.Len()))
|
|
|
|
en := msgp.NewWriter(msgp.Nowhere)
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
v.EncodeMsg(en)
|
|
|
|
}
|
|
|
|
en.Flush()
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkDecodedataUsageEntryV5(b *testing.B) {
|
|
|
|
v := dataUsageEntryV5{}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
b.SetBytes(int64(buf.Len()))
|
|
|
|
rd := msgp.NewEndlessReader(buf.Bytes(), b)
|
|
|
|
dc := msgp.NewReader(rd)
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
err := v.DecodeMsg(dc)
|
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMarshalUnmarshalreplicationAllStats(t *testing.T) {
|
|
|
|
v := replicationAllStats{}
|
|
|
|
bts, err := v.MarshalMsg(nil)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
left, err := v.UnmarshalMsg(bts)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if len(left) > 0 {
|
|
|
|
t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
|
|
|
|
}
|
|
|
|
|
|
|
|
left, err = msgp.Skip(bts)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if len(left) > 0 {
|
|
|
|
t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkMarshalMsgreplicationAllStats(b *testing.B) {
|
|
|
|
v := replicationAllStats{}
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
v.MarshalMsg(nil)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkAppendMsgreplicationAllStats(b *testing.B) {
|
|
|
|
v := replicationAllStats{}
|
|
|
|
bts := make([]byte, 0, v.Msgsize())
|
|
|
|
bts, _ = v.MarshalMsg(bts[0:0])
|
|
|
|
b.SetBytes(int64(len(bts)))
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
bts, _ = v.MarshalMsg(bts[0:0])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkUnmarshalreplicationAllStats(b *testing.B) {
|
|
|
|
v := replicationAllStats{}
|
|
|
|
bts, _ := v.MarshalMsg(nil)
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.SetBytes(int64(len(bts)))
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_, err := v.UnmarshalMsg(bts)
|
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestEncodeDecodereplicationAllStats(t *testing.T) {
|
|
|
|
v := replicationAllStats{}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
|
|
|
|
m := v.Msgsize()
|
|
|
|
if buf.Len() > m {
|
|
|
|
t.Log("WARNING: TestEncodeDecodereplicationAllStats Msgsize() is inaccurate")
|
|
|
|
}
|
|
|
|
|
|
|
|
vn := replicationAllStats{}
|
|
|
|
err := msgp.Decode(&buf, &vn)
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
err = msgp.NewReader(&buf).Skip()
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkEncodereplicationAllStats(b *testing.B) {
|
|
|
|
v := replicationAllStats{}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
b.SetBytes(int64(buf.Len()))
|
|
|
|
en := msgp.NewWriter(msgp.Nowhere)
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
v.EncodeMsg(en)
|
|
|
|
}
|
|
|
|
en.Flush()
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkDecodereplicationAllStats(b *testing.B) {
|
|
|
|
v := replicationAllStats{}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
b.SetBytes(int64(buf.Len()))
|
|
|
|
rd := msgp.NewEndlessReader(buf.Bytes(), b)
|
|
|
|
dc := msgp.NewReader(rd)
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
err := v.DecodeMsg(dc)
|
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-03 12:03:42 -04:00
|
|
|
func TestMarshalUnmarshalreplicationStats(t *testing.T) {
|
|
|
|
v := replicationStats{}
|
|
|
|
bts, err := v.MarshalMsg(nil)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
left, err := v.UnmarshalMsg(bts)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if len(left) > 0 {
|
|
|
|
t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
|
|
|
|
}
|
|
|
|
|
|
|
|
left, err = msgp.Skip(bts)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if len(left) > 0 {
|
|
|
|
t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkMarshalMsgreplicationStats(b *testing.B) {
|
|
|
|
v := replicationStats{}
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
v.MarshalMsg(nil)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkAppendMsgreplicationStats(b *testing.B) {
|
|
|
|
v := replicationStats{}
|
|
|
|
bts := make([]byte, 0, v.Msgsize())
|
|
|
|
bts, _ = v.MarshalMsg(bts[0:0])
|
|
|
|
b.SetBytes(int64(len(bts)))
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
bts, _ = v.MarshalMsg(bts[0:0])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkUnmarshalreplicationStats(b *testing.B) {
|
|
|
|
v := replicationStats{}
|
|
|
|
bts, _ := v.MarshalMsg(nil)
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.SetBytes(int64(len(bts)))
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_, err := v.UnmarshalMsg(bts)
|
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestEncodeDecodereplicationStats(t *testing.T) {
|
|
|
|
v := replicationStats{}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
|
|
|
|
m := v.Msgsize()
|
|
|
|
if buf.Len() > m {
|
|
|
|
t.Log("WARNING: TestEncodeDecodereplicationStats Msgsize() is inaccurate")
|
|
|
|
}
|
|
|
|
|
|
|
|
vn := replicationStats{}
|
|
|
|
err := msgp.Decode(&buf, &vn)
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
err = msgp.NewReader(&buf).Skip()
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkEncodereplicationStats(b *testing.B) {
|
|
|
|
v := replicationStats{}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
b.SetBytes(int64(buf.Len()))
|
|
|
|
en := msgp.NewWriter(msgp.Nowhere)
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
v.EncodeMsg(en)
|
|
|
|
}
|
|
|
|
en.Flush()
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkDecodereplicationStats(b *testing.B) {
|
|
|
|
v := replicationStats{}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
b.SetBytes(int64(buf.Len()))
|
|
|
|
rd := msgp.NewEndlessReader(buf.Bytes(), b)
|
|
|
|
dc := msgp.NewReader(rd)
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
err := v.DecodeMsg(dc)
|
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-18 19:19:29 -04:00
|
|
|
func TestMarshalUnmarshalsizeHistogram(t *testing.T) {
|
|
|
|
v := sizeHistogram{}
|
|
|
|
bts, err := v.MarshalMsg(nil)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
left, err := v.UnmarshalMsg(bts)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if len(left) > 0 {
|
|
|
|
t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
|
|
|
|
}
|
|
|
|
|
|
|
|
left, err = msgp.Skip(bts)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if len(left) > 0 {
|
|
|
|
t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkMarshalMsgsizeHistogram(b *testing.B) {
|
|
|
|
v := sizeHistogram{}
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
v.MarshalMsg(nil)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkAppendMsgsizeHistogram(b *testing.B) {
|
|
|
|
v := sizeHistogram{}
|
|
|
|
bts := make([]byte, 0, v.Msgsize())
|
|
|
|
bts, _ = v.MarshalMsg(bts[0:0])
|
|
|
|
b.SetBytes(int64(len(bts)))
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
bts, _ = v.MarshalMsg(bts[0:0])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkUnmarshalsizeHistogram(b *testing.B) {
|
|
|
|
v := sizeHistogram{}
|
|
|
|
bts, _ := v.MarshalMsg(nil)
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.SetBytes(int64(len(bts)))
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_, err := v.UnmarshalMsg(bts)
|
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestEncodeDecodesizeHistogram(t *testing.T) {
|
|
|
|
v := sizeHistogram{}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
|
|
|
|
m := v.Msgsize()
|
|
|
|
if buf.Len() > m {
|
|
|
|
t.Log("WARNING: TestEncodeDecodesizeHistogram Msgsize() is inaccurate")
|
|
|
|
}
|
|
|
|
|
|
|
|
vn := sizeHistogram{}
|
|
|
|
err := msgp.Decode(&buf, &vn)
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
err = msgp.NewReader(&buf).Skip()
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkEncodesizeHistogram(b *testing.B) {
|
|
|
|
v := sizeHistogram{}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
b.SetBytes(int64(buf.Len()))
|
|
|
|
en := msgp.NewWriter(msgp.Nowhere)
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
v.EncodeMsg(en)
|
|
|
|
}
|
|
|
|
en.Flush()
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkDecodesizeHistogram(b *testing.B) {
|
|
|
|
v := sizeHistogram{}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
b.SetBytes(int64(buf.Len()))
|
|
|
|
rd := msgp.NewEndlessReader(buf.Bytes(), b)
|
|
|
|
dc := msgp.NewReader(rd)
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
err := v.DecodeMsg(dc)
|
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|