diff --git a/bench_v2_test.go b/bench_test.go similarity index 75% rename from bench_v2_test.go rename to bench_test.go index 03c58fa..d7c5dfd 100644 --- a/bench_v2_test.go +++ b/bench_test.go @@ -16,7 +16,7 @@ func benchPayload() []byte { var preparedPayload = benchPayload() -func marshalProtobufV2() ([]byte, *Reply, error) { +func marshalProtobuf() ([]byte, *Reply, error) { r := &Reply{ Push: &Push{ Channel: "test", @@ -33,7 +33,7 @@ func marshalProtobufV2() ([]byte, *Reply, error) { return res, r, nil } -func marshalJSONV2() ([]byte, *Reply, error) { +func marshalJSON() ([]byte, *Reply, error) { r := &Reply{ Push: &Push{ Channel: "test", @@ -59,9 +59,9 @@ var benchReply *Reply //goland:noinspection GoUnusedGlobalVariable var benchConnectRequest *ConnectRequest -func BenchmarkReplyProtobufMarshalV2(b *testing.B) { +func BenchmarkReplyProtobufMarshal(b *testing.B) { for i := 0; i < b.N; i++ { - d, r, err := marshalProtobufV2() + d, r, err := marshalProtobuf() if err != nil { b.Fatal(err) } @@ -71,11 +71,11 @@ func BenchmarkReplyProtobufMarshalV2(b *testing.B) { b.ReportAllocs() } -func BenchmarkReplyProtobufMarshalParallelV2(b *testing.B) { +func BenchmarkReplyProtobufMarshalParallel(b *testing.B) { b.ReportAllocs() b.RunParallel(func(pb *testing.PB) { for pb.Next() { - d, r, err := marshalProtobufV2() + d, r, err := marshalProtobuf() if err != nil { b.Fatal(err) } @@ -85,9 +85,9 @@ func BenchmarkReplyProtobufMarshalParallelV2(b *testing.B) { }) } -func BenchmarkReplyJSONMarshalV2(b *testing.B) { +func BenchmarkReplyJSONMarshal(b *testing.B) { for i := 0; i < b.N; i++ { - d, r, err := marshalJSONV2() + d, r, err := marshalJSON() if err != nil { b.Fatal(err) } @@ -97,11 +97,11 @@ func BenchmarkReplyJSONMarshalV2(b *testing.B) { b.ReportAllocs() } -func BenchmarkReplyJSONMarshalParallelV2(b *testing.B) { +func BenchmarkReplyJSONMarshalParallel(b *testing.B) { b.ReportAllocs() b.RunParallel(func(pb *testing.PB) { for pb.Next() { - d, r, err := marshalJSONV2() + d, r, err := marshalJSON() if err != nil { b.Fatal(err) } @@ -111,7 +111,7 @@ func BenchmarkReplyJSONMarshalParallelV2(b *testing.B) { }) } -func BenchmarkReplyProtobufUnmarshalV2(b *testing.B) { +func BenchmarkReplyProtobufUnmarshal(b *testing.B) { params := &ConnectRequest{ Token: "token", } @@ -123,12 +123,12 @@ func BenchmarkReplyProtobufUnmarshalV2(b *testing.B) { data, _ := encoder.Encode(cmd) b.ResetTimer() for i := 0; i < b.N; i++ { - benchConnectRequest = unmarshalProtobufV2(b, data) + benchConnectRequest = unmarshalProtobuf(b, data) } b.ReportAllocs() } -func BenchmarkReplyProtobufUnmarshalParallelV2(b *testing.B) { +func BenchmarkReplyProtobufUnmarshalParallel(b *testing.B) { params := &ConnectRequest{ Token: "token", } @@ -141,13 +141,13 @@ func BenchmarkReplyProtobufUnmarshalParallelV2(b *testing.B) { b.ResetTimer() b.RunParallel(func(pb *testing.PB) { for pb.Next() { - benchConnectRequest = unmarshalProtobufV2(b, data) + benchConnectRequest = unmarshalProtobuf(b, data) } }) b.ReportAllocs() } -func unmarshalProtobufV2(b *testing.B, data []byte) *ConnectRequest { +func unmarshalProtobuf(b *testing.B, data []byte) *ConnectRequest { decoder := GetCommandDecoder(TypeProtobuf, data) defer PutCommandDecoder(TypeProtobuf, decoder) cmd, err := decoder.Decode() @@ -166,7 +166,7 @@ func unmarshalProtobufV2(b *testing.B, data []byte) *ConnectRequest { return cmd.Connect } -func BenchmarkReplyJSONUnmarshalV2(b *testing.B) { +func BenchmarkReplyJSONUnmarshal(b *testing.B) { params := &ConnectRequest{ Token: "token", } @@ -178,12 +178,12 @@ func BenchmarkReplyJSONUnmarshalV2(b *testing.B) { data, _ := encoder.Encode(cmd) b.ResetTimer() for i := 0; i < b.N; i++ { - benchConnectRequest = unmarshalJSONV2(b, data) + benchConnectRequest = unmarshalJSON(b, data) } b.ReportAllocs() } -func BenchmarkReplyJSONUnmarshalParallelV2(b *testing.B) { +func BenchmarkReplyJSONUnmarshalParallel(b *testing.B) { params := &ConnectRequest{ Token: "token", } @@ -196,13 +196,13 @@ func BenchmarkReplyJSONUnmarshalParallelV2(b *testing.B) { b.ResetTimer() b.RunParallel(func(pb *testing.PB) { for pb.Next() { - benchConnectRequest = unmarshalJSONV2(b, data) + benchConnectRequest = unmarshalJSON(b, data) } }) b.ReportAllocs() } -func unmarshalJSONV2(b *testing.B, data []byte) *ConnectRequest { +func unmarshalJSON(b *testing.B, data []byte) *ConnectRequest { decoder := GetCommandDecoder(TypeJSON, data) defer PutCommandDecoder(TypeJSON, decoder) cmd, err := decoder.Decode() diff --git a/client.pb.go b/client.pb.go index 4cdb639..a61cbfa 100644 --- a/client.pb.go +++ b/client.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.27.1 -// protoc v3.17.3 +// protoc-gen-go v1.31.0 +// protoc v4.23.4 // source: client.proto package protocol diff --git a/client_vtproto.pb.go b/client_vtproto.pb.go index 4c2f3a5..0058074 100644 --- a/client_vtproto.pb.go +++ b/client_vtproto.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-go-vtproto. DO NOT EDIT. -// protoc-gen-go-vtproto version: v0.3.0 +// protoc-gen-go-vtproto version: v0.5.0 // source: client.proto package protocol @@ -2527,9 +2527,7 @@ func (m *Error) SizeVT() (n int) { if m.Temporary { n += 2 } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -2551,9 +2549,7 @@ func (m *EmulationRequest) SizeVT() (n int) { if l > 0 { n += 1 + l + sov(uint64(l)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -2614,9 +2610,7 @@ func (m *Command) SizeVT() (n int) { l = m.SubRefresh.SizeVT() n += 1 + l + sov(uint64(l)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -2681,9 +2675,7 @@ func (m *Reply) SizeVT() (n int) { l = m.SubRefresh.SizeVT() n += 1 + l + sov(uint64(l)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -2733,9 +2725,7 @@ func (m *Push) SizeVT() (n int) { l = m.Refresh.SizeVT() n += 1 + l + sov(uint64(l)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -2761,9 +2751,7 @@ func (m *ClientInfo) SizeVT() (n int) { if l > 0 { n += 1 + l + sov(uint64(l)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -2792,9 +2780,7 @@ func (m *Publication) SizeVT() (n int) { n += mapEntrySize + 1 + sov(uint64(mapEntrySize)) } } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -2808,9 +2794,7 @@ func (m *Join) SizeVT() (n int) { l = m.Info.SizeVT() n += 1 + l + sov(uint64(l)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -2824,9 +2808,7 @@ func (m *Leave) SizeVT() (n int) { l = m.Info.SizeVT() n += 1 + l + sov(uint64(l)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -2843,9 +2825,7 @@ func (m *Unsubscribe) SizeVT() (n int) { if l > 0 { n += 1 + l + sov(uint64(l)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -2872,9 +2852,7 @@ func (m *Subscribe) SizeVT() (n int) { if l > 0 { n += 1 + l + sov(uint64(l)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -2888,9 +2866,7 @@ func (m *Message) SizeVT() (n int) { if l > 0 { n += 1 + l + sov(uint64(l)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -2945,9 +2921,7 @@ func (m *Connect) SizeVT() (n int) { if l > 0 { n += 1 + l + sov(uint64(l)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -2967,9 +2941,7 @@ func (m *Disconnect) SizeVT() (n int) { if m.Reconnect { n += 2 } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -2985,9 +2957,7 @@ func (m *Refresh) SizeVT() (n int) { if m.Ttl != 0 { n += 1 + sov(uint64(m.Ttl)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -3026,9 +2996,7 @@ func (m *ConnectRequest) SizeVT() (n int) { if l > 0 { n += 1 + l + sov(uint64(l)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -3083,9 +3051,7 @@ func (m *ConnectResult) SizeVT() (n int) { if l > 0 { n += 1 + l + sov(uint64(l)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -3099,9 +3065,7 @@ func (m *RefreshRequest) SizeVT() (n int) { if l > 0 { n += 1 + l + sov(uint64(l)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -3125,9 +3089,7 @@ func (m *RefreshResult) SizeVT() (n int) { if m.Ttl != 0 { n += 1 + sov(uint64(m.Ttl)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -3168,9 +3130,7 @@ func (m *SubscribeRequest) SizeVT() (n int) { if m.JoinLeave { n += 2 } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -3215,9 +3175,7 @@ func (m *SubscribeResult) SizeVT() (n int) { if m.WasRecovering { n += 2 } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -3235,9 +3193,7 @@ func (m *SubRefreshRequest) SizeVT() (n int) { if l > 0 { n += 1 + l + sov(uint64(l)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -3253,9 +3209,7 @@ func (m *SubRefreshResult) SizeVT() (n int) { if m.Ttl != 0 { n += 1 + sov(uint64(m.Ttl)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -3269,9 +3223,7 @@ func (m *UnsubscribeRequest) SizeVT() (n int) { if l > 0 { n += 1 + l + sov(uint64(l)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -3281,9 +3233,7 @@ func (m *UnsubscribeResult) SizeVT() (n int) { } var l int _ = l - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -3301,9 +3251,7 @@ func (m *PublishRequest) SizeVT() (n int) { if l > 0 { n += 1 + l + sov(uint64(l)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -3313,9 +3261,7 @@ func (m *PublishResult) SizeVT() (n int) { } var l int _ = l - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -3329,9 +3275,7 @@ func (m *PresenceRequest) SizeVT() (n int) { if l > 0 { n += 1 + l + sov(uint64(l)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -3354,9 +3298,7 @@ func (m *PresenceResult) SizeVT() (n int) { n += mapEntrySize + 1 + sov(uint64(mapEntrySize)) } } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -3370,9 +3312,7 @@ func (m *PresenceStatsRequest) SizeVT() (n int) { if l > 0 { n += 1 + l + sov(uint64(l)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -3388,9 +3328,7 @@ func (m *PresenceStatsResult) SizeVT() (n int) { if m.NumUsers != 0 { n += 1 + sov(uint64(m.NumUsers)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -3407,9 +3345,7 @@ func (m *StreamPosition) SizeVT() (n int) { if l > 0 { n += 1 + l + sov(uint64(l)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -3433,9 +3369,7 @@ func (m *HistoryRequest) SizeVT() (n int) { if m.Reverse { n += 2 } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -3458,9 +3392,7 @@ func (m *HistoryResult) SizeVT() (n int) { if m.Offset != 0 { n += 1 + sov(uint64(m.Offset)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -3470,9 +3402,7 @@ func (m *PingRequest) SizeVT() (n int) { } var l int _ = l - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -3482,9 +3412,7 @@ func (m *PingResult) SizeVT() (n int) { } var l int _ = l - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -3502,9 +3430,7 @@ func (m *RPCRequest) SizeVT() (n int) { if l > 0 { n += 1 + l + sov(uint64(l)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -3518,9 +3444,7 @@ func (m *RPCResult) SizeVT() (n int) { if l > 0 { n += 1 + l + sov(uint64(l)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -3534,9 +3458,7 @@ func (m *SendRequest) SizeVT() (n int) { if l > 0 { n += 1 + l + sov(uint64(l)) } - if m.unknownFields != nil { - n += len(m.unknownFields) - } + n += len(m.unknownFields) return n } @@ -10146,6 +10068,7 @@ func (m *SendRequest) UnmarshalVT(dAtA []byte) error { } return nil } + func skip(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0