aboutsummaryrefslogtreecommitdiff
path: root/io_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'io_test.go')
-rw-r--r--io_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/io_test.go b/io_test.go
index 582dd1e..dddcf65 100644
--- a/io_test.go
+++ b/io_test.go
@@ -3,6 +3,7 @@ package rabbitio_test
import (
"bytes"
"encoding/hex"
+ "fmt"
"io"
"strings"
"testing"
@@ -103,3 +104,30 @@ func TestNewCipher(t *testing.T) {
}
}
+
+func BenchmarkNewCipher(b *testing.B) {
+ b.Run(fmt.Sprintf("bench %v", b.N), func(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ key, ivt := []byte("12345678abcdefgh"), []byte("1234qwer")
+ txt := "test NewReadercipher text dummy tx"
+ cph, err := rabbitio.NewCipher(key, ivt)
+ if err != nil {
+ b.Fatal(err)
+ }
+ dst := make([]byte, len(txt))
+ cph.XORKeyStream(dst, []byte(txt))
+
+ cph, err = rabbitio.NewCipher(key, ivt)
+ if err != nil {
+ b.Fatal(err)
+ }
+
+ nds := make([]byte, len(dst))
+ cph.XORKeyStream(nds, dst)
+ if string(nds) != txt {
+ b.Error("error: nds is not equal to txt")
+ }
+ }
+ })
+
+}

Snix LLC Git Repository Holder Copyright(C) 2022 All Rights Reserved Email To Snix.IR