From 994898c97a6ca03c83549db9aeb8b631ba1defc7 Mon Sep 17 00:00:00 2001 From: Eric Yan Date: Thu, 6 Jul 2017 21:43:53 +0800 Subject: [PATCH] Benchmark XORKeyStream --- stream/stream_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/stream/stream_test.go b/stream/stream_test.go index b688d8f..ace6cf9 100644 --- a/stream/stream_test.go +++ b/stream/stream_test.go @@ -25,3 +25,15 @@ func TestStreamCipher(t *testing.T) { } } } + +func BenchmarkXORKeyStream(b *testing.B) { + plaintext := make([]byte, 1500) + ciphertext := make([]byte, len(plaintext)) + c := NewCipher(new(fakePRNG)) + + b.ResetTimer() + for n := 0; n < b.N; n++ { + c.XORKeyStream(ciphertext, plaintext) + } + b.SetBytes(int64(len(plaintext))) +}