From 8668d49c9d14b063d8c363e0abd3e0bf7e0120e8 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Wed, 6 Oct 2021 01:25:37 -0700 Subject: [PATCH] test with real redis cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz BenchmarkNameList-12 1789 760599 ns/op BenchmarkRedis-12 17539 64122 ns/op PASS --- .../redis3/kv_directory_children_test.go | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/weed/filer/redis3/kv_directory_children_test.go b/weed/filer/redis3/kv_directory_children_test.go index 1b97d8aaf..5c1cff2bb 100644 --- a/weed/filer/redis3/kv_directory_children_test.go +++ b/weed/filer/redis3/kv_directory_children_test.go @@ -117,3 +117,44 @@ func BenchmarkRedis(b *testing.B) { client.ZAddNX(context.Background(),"/yyy/bin", &redis.Z{Score: 0, Member: "name"+strconv.Itoa(i)}) } } + + +func xBenchmarkNameList(b *testing.B) { + + server, err := tempredis.Start(tempredis.Config{}) + if err != nil { + panic(err) + } + defer server.Term() + + client := redis.NewClient(&redis.Options{ + Addr: "localhost:6379", + Password: "", + DB: 0, + }) + + store := newSkipListElementStore("/yyy/bin", client) + var data []byte + for i := 0; i < b.N; i++ { + nameList := skiplist.LoadNameList(data, store, maxNameBatchSizeLimit) + + nameList.WriteName("name"+strconv.Itoa(i)) + + if nameList.HasChanges() { + data = nameList.ToBytes() + } + } +} + +func xBenchmarkRedis(b *testing.B) { + + client := redis.NewClient(&redis.Options{ + Addr: "localhost:6379", + Password: "", + DB: 0, + }) + + for i := 0; i < b.N; i++ { + client.ZAddNX(context.Background(),"/xxx/bin", &redis.Z{Score: 0, Member: "name"+strconv.Itoa(i)}) + } +}