From fbb996aadf8cacbdba2f23e35a057070c3d51d8d Mon Sep 17 00:00:00 2001 From: vicanso Date: Sun, 13 Aug 2023 21:36:34 +0800 Subject: [PATCH] refactor: add bench test --- middleware/lru_store_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/middleware/lru_store_test.go b/middleware/lru_store_test.go index 6fcd413..3b710bb 100644 --- a/middleware/lru_store_test.go +++ b/middleware/lru_store_test.go @@ -48,3 +48,12 @@ func TestLruStore(t *testing.T) { buf, _ = store.Get(ctx, key1) assert.Empty(buf) } + +func BenchmarkLruStore(b *testing.B) { + store := NewLruStore(128) + ctx := context.Background() + for i := 0; i < b.N; i++ { + _ = store.Set(ctx, "key", []byte("Hello world!"), time.Second) + _, _ = store.Get(ctx, "key") + } +}