From ec0075ebba419f6189130d578fe3cbb00584e9e2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 6 Nov 2021 06:13:38 +0000 Subject: [PATCH 1/2] ci(chore): Fix stylings --- client/pb/channel/unknown.pb.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/pb/channel/unknown.pb.go b/client/pb/channel/unknown.pb.go index 5e132372..4a0eaef9 100644 --- a/client/pb/channel/unknown.pb.go +++ b/client/pb/channel/unknown.pb.go @@ -9,10 +9,11 @@ package channel import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( From 7e2033fd75aad310088b72290bf97b92e7afc741 Mon Sep 17 00:00:00 2001 From: wdvxdr Date: Sat, 6 Nov 2021 14:41:47 +0800 Subject: [PATCH 2/2] test: unify tea benchmark --- binary/tea_test.go | 55 +++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/binary/tea_test.go b/binary/tea_test.go index 08831c11..c0c9d841 100644 --- a/binary/tea_test.go +++ b/binary/tea_test.go @@ -75,52 +75,57 @@ func TestTEA(t *testing.T) { } } -func BenchmarkTEAen16(b *testing.B) { - data := make([]byte, 16) +func benchEncrypt(b *testing.B, data []byte) { _, err := rand.Read(data) if err != nil { panic(err) } + b.SetBytes(int64(len(data))) b.ResetTimer() for i := 0; i < b.N; i++ { testTEA.Encrypt(data) } } -func BenchmarkTEAde16(b *testing.B) { - data := make([]byte, 16) +func benchDecrypt(b *testing.B, data []byte) { _, err := rand.Read(data) if err != nil { panic(err) } data = testTEA.Encrypt(data) + b.SetBytes(int64(len(data))) b.ResetTimer() for i := 0; i < b.N; i++ { testTEA.Decrypt(data) } } -func BenchmarkTEAen256(b *testing.B) { - data := make([]byte, 256) - _, err := rand.Read(data) - if err != nil { - panic(err) - } - b.ResetTimer() - for i := 0; i < b.N; i++ { - testTEA.Encrypt(data) - } +func BenchmarkTEAen(b *testing.B) { + b.Run("16", func(b *testing.B) { + data := make([]byte, 16) + benchEncrypt(b, data) + }) + b.Run("256", func(b *testing.B) { + data := make([]byte, 256) + benchEncrypt(b, data) + }) + b.Run("4K", func(b *testing.B) { + data := make([]byte, 4096) + benchEncrypt(b, data) + }) } -func BenchmarkTEAde256(b *testing.B) { - data := make([]byte, 256) - _, err := rand.Read(data) - if err != nil { - panic(err) - } - data = testTEA.Encrypt(data) - b.ResetTimer() - for i := 0; i < b.N; i++ { - testTEA.Decrypt(data) - } +func BenchmarkTEAde(b *testing.B) { + b.Run("16", func(b *testing.B) { + data := make([]byte, 16) + benchDecrypt(b, data) + }) + b.Run("256", func(b *testing.B) { + data := make([]byte, 256) + benchDecrypt(b, data) + }) + b.Run("4K", func(b *testing.B) { + data := make([]byte, 4096) + benchDecrypt(b, data) + }) }