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"
|
|
|
|
)
|
|
|
|
|
2021-10-23 21:38:33 -04:00
|
|
|
func TestMarshalUnmarshalallTierStats(t *testing.T) {
|
|
|
|
v := allTierStats{}
|
|
|
|
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 BenchmarkMarshalMsgallTierStats(b *testing.B) {
|
|
|
|
v := allTierStats{}
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
v.MarshalMsg(nil)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkAppendMsgallTierStats(b *testing.B) {
|
|
|
|
v := allTierStats{}
|
|
|
|
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 BenchmarkUnmarshalallTierStats(b *testing.B) {
|
|
|
|
v := allTierStats{}
|
|
|
|
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 TestEncodeDecodeallTierStats(t *testing.T) {
|
|
|
|
v := allTierStats{}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
|
|
|
|
m := v.Msgsize()
|
|
|
|
if buf.Len() > m {
|
|
|
|
t.Log("WARNING: TestEncodeDecodeallTierStats Msgsize() is inaccurate")
|
|
|
|
}
|
|
|
|
|
|
|
|
vn := allTierStats{}
|
|
|
|
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 BenchmarkEncodeallTierStats(b *testing.B) {
|
|
|
|
v := allTierStats{}
|
|
|
|
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 BenchmarkDecodeallTierStats(b *testing.B) {
|
|
|
|
v := allTierStats{}
|
|
|
|
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-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-10-23 21:38:33 -04:00
|
|
|
func TestMarshalUnmarshalreplicationAllStats(t *testing.T) {
|
|
|
|
v := replicationAllStats{}
|
2021-09-18 16:31:35 -04:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-23 21:38:33 -04:00
|
|
|
func BenchmarkMarshalMsgreplicationAllStats(b *testing.B) {
|
|
|
|
v := replicationAllStats{}
|
2021-09-18 16:31:35 -04:00
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
v.MarshalMsg(nil)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-23 21:38:33 -04:00
|
|
|
func BenchmarkAppendMsgreplicationAllStats(b *testing.B) {
|
|
|
|
v := replicationAllStats{}
|
2021-09-18 16:31:35 -04:00
|
|
|
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])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-23 21:38:33 -04:00
|
|
|
func BenchmarkUnmarshalreplicationAllStats(b *testing.B) {
|
|
|
|
v := replicationAllStats{}
|
2021-09-18 16:31:35 -04:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-23 21:38:33 -04:00
|
|
|
func TestEncodeDecodereplicationAllStats(t *testing.T) {
|
|
|
|
v := replicationAllStats{}
|
2021-09-18 16:31:35 -04:00
|
|
|
var buf bytes.Buffer
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
|
|
|
|
m := v.Msgsize()
|
|
|
|
if buf.Len() > m {
|
2021-10-23 21:38:33 -04:00
|
|
|
t.Log("WARNING: TestEncodeDecodereplicationAllStats Msgsize() is inaccurate")
|
2021-09-18 16:31:35 -04:00
|
|
|
}
|
|
|
|
|
2021-10-23 21:38:33 -04:00
|
|
|
vn := replicationAllStats{}
|
2021-09-18 16:31:35 -04:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-23 21:38:33 -04:00
|
|
|
func BenchmarkEncodereplicationAllStats(b *testing.B) {
|
|
|
|
v := replicationAllStats{}
|
2021-09-18 16:31:35 -04:00
|
|
|
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()
|
|
|
|
}
|
|
|
|
|
2021-10-23 21:38:33 -04:00
|
|
|
func BenchmarkDecodereplicationAllStats(b *testing.B) {
|
|
|
|
v := replicationAllStats{}
|
2021-09-18 16:31:35 -04:00
|
|
|
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-10-23 21:38:33 -04:00
|
|
|
func TestMarshalUnmarshalreplicationAllStatsV1(t *testing.T) {
|
|
|
|
v := replicationAllStatsV1{}
|
2021-09-18 16:31:35 -04:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-23 21:38:33 -04:00
|
|
|
func BenchmarkMarshalMsgreplicationAllStatsV1(b *testing.B) {
|
|
|
|
v := replicationAllStatsV1{}
|
2021-09-18 16:31:35 -04:00
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
v.MarshalMsg(nil)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-23 21:38:33 -04:00
|
|
|
func BenchmarkAppendMsgreplicationAllStatsV1(b *testing.B) {
|
|
|
|
v := replicationAllStatsV1{}
|
2021-09-18 16:31:35 -04:00
|
|
|
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])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-23 21:38:33 -04:00
|
|
|
func BenchmarkUnmarshalreplicationAllStatsV1(b *testing.B) {
|
|
|
|
v := replicationAllStatsV1{}
|
2021-09-18 16:31:35 -04:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-23 21:38:33 -04:00
|
|
|
func TestEncodeDecodereplicationAllStatsV1(t *testing.T) {
|
|
|
|
v := replicationAllStatsV1{}
|
2021-09-18 16:31:35 -04:00
|
|
|
var buf bytes.Buffer
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
|
|
|
|
m := v.Msgsize()
|
|
|
|
if buf.Len() > m {
|
2021-10-23 21:38:33 -04:00
|
|
|
t.Log("WARNING: TestEncodeDecodereplicationAllStatsV1 Msgsize() is inaccurate")
|
2021-09-18 16:31:35 -04:00
|
|
|
}
|
|
|
|
|
2021-10-23 21:38:33 -04:00
|
|
|
vn := replicationAllStatsV1{}
|
2021-09-18 16:31:35 -04:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-23 21:38:33 -04:00
|
|
|
func BenchmarkEncodereplicationAllStatsV1(b *testing.B) {
|
|
|
|
v := replicationAllStatsV1{}
|
2021-09-18 16:31:35 -04:00
|
|
|
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()
|
|
|
|
}
|
|
|
|
|
2021-10-23 21:38:33 -04:00
|
|
|
func BenchmarkDecodereplicationAllStatsV1(b *testing.B) {
|
|
|
|
v := replicationAllStatsV1{}
|
2021-09-18 16:31:35 -04:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-21 12:01:51 -04:00
|
|
|
func TestMarshalUnmarshalreplicationStatsV1(t *testing.T) {
|
|
|
|
v := replicationStatsV1{}
|
|
|
|
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 BenchmarkMarshalMsgreplicationStatsV1(b *testing.B) {
|
|
|
|
v := replicationStatsV1{}
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
v.MarshalMsg(nil)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkAppendMsgreplicationStatsV1(b *testing.B) {
|
|
|
|
v := replicationStatsV1{}
|
|
|
|
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 BenchmarkUnmarshalreplicationStatsV1(b *testing.B) {
|
|
|
|
v := replicationStatsV1{}
|
|
|
|
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 TestEncodeDecodereplicationStatsV1(t *testing.T) {
|
|
|
|
v := replicationStatsV1{}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
|
|
|
|
m := v.Msgsize()
|
|
|
|
if buf.Len() > m {
|
|
|
|
t.Log("WARNING: TestEncodeDecodereplicationStatsV1 Msgsize() is inaccurate")
|
|
|
|
}
|
|
|
|
|
|
|
|
vn := replicationStatsV1{}
|
|
|
|
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 BenchmarkEncodereplicationStatsV1(b *testing.B) {
|
|
|
|
v := replicationStatsV1{}
|
|
|
|
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 BenchmarkDecodereplicationStatsV1(b *testing.B) {
|
|
|
|
v := replicationStatsV1{}
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-10-23 21:38:33 -04:00
|
|
|
|
|
|
|
func TestMarshalUnmarshaltierStats(t *testing.T) {
|
|
|
|
v := tierStats{}
|
|
|
|
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 BenchmarkMarshalMsgtierStats(b *testing.B) {
|
|
|
|
v := tierStats{}
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
v.MarshalMsg(nil)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkAppendMsgtierStats(b *testing.B) {
|
|
|
|
v := tierStats{}
|
|
|
|
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 BenchmarkUnmarshaltierStats(b *testing.B) {
|
|
|
|
v := tierStats{}
|
|
|
|
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 TestEncodeDecodetierStats(t *testing.T) {
|
|
|
|
v := tierStats{}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
msgp.Encode(&buf, &v)
|
|
|
|
|
|
|
|
m := v.Msgsize()
|
|
|
|
if buf.Len() > m {
|
|
|
|
t.Log("WARNING: TestEncodeDecodetierStats Msgsize() is inaccurate")
|
|
|
|
}
|
|
|
|
|
|
|
|
vn := tierStats{}
|
|
|
|
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 BenchmarkEncodetierStats(b *testing.B) {
|
|
|
|
v := tierStats{}
|
|
|
|
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 BenchmarkDecodetierStats(b *testing.B) {
|
|
|
|
v := tierStats{}
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|