Skip to content

Commit

Permalink
correct bench test write radio
Browse files Browse the repository at this point in the history
  • Loading branch information
phuslu committed Jan 3, 2024
1 parent ff379c6 commit 53a77c3
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ A Performance result as below. Check [actions][actions] for more results and det
keysize = 16
cachesize = 1000000
parallelism = 32
writepercent = 10
writeradio = 0.1
)

var keymap = func() (x []string) {
Expand All @@ -118,9 +118,10 @@ A Performance result as below. Check [actions][actions] for more results and det
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
expires := time.Now().Add(time.Hour)
waterlevel := int(float32(cachesize) * writeradio)
for pb.Next() {
i := int(fastrandn(cachesize))
if i <= cachesize/writepercent {
if i <= waterlevel {
cache.Set(keymap[i], i, expires)
} else {
cache.Get(keymap[i])
Expand All @@ -137,9 +138,10 @@ A Performance result as below. Check [actions][actions] for more results and det
b.SetParallelism(parallelism)
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
waterlevel := int(float32(cachesize) * writeradio)
for pb.Next() {
i := int(fastrandn(cachesize))
if i <= cachesize/writepercent {
if i <= waterlevel {
cache.Put(keymap[i], i)
} else {
cache.Get(keymap[i])
Expand All @@ -162,9 +164,10 @@ A Performance result as below. Check [actions][actions] for more results and det
b.ResetTimer()

b.RunParallel(func(pb *testing.PB) {
waterlevel := int(float32(cachesize) * writeradio)
for pb.Next() {
i := int(fastrandn(cachesize))
if i <= cachesize/writepercent {
if i <= waterlevel {
cache.SetWithTTL(keymap[i], i, 1, time.Hour)
} else {
cache.Get(keymap[i])
Expand All @@ -183,9 +186,10 @@ A Performance result as below. Check [actions][actions] for more results and det
b.ResetTimer()

b.RunParallel(func(pb *testing.PB) {
waterlevel := int(float32(cachesize) * writeradio)
for pb.Next() {
i := int(fastrandn(cachesize))
if i <= cachesize/writepercent {
if i <= waterlevel {
cache.SetWithTTL(keymap[i], i, 1, time.Hour)
} else {
cache.Get(keymap[i])
Expand All @@ -204,9 +208,10 @@ A Performance result as below. Check [actions][actions] for more results and det
b.ResetTimer()

b.RunParallel(func(pb *testing.PB) {
waterlevel := int(float32(cachesize) * writeradio)
for pb.Next() {
i := int(fastrandn(cachesize))
if i <= cachesize/writepercent {
if i <= waterlevel {
cache.SetWithTTL(keymap[i], i, time.Hour)
} else {
cache.Get(keymap[i])
Expand All @@ -229,9 +234,10 @@ A Performance result as below. Check [actions][actions] for more results and det
b.ResetTimer()

b.RunParallel(func(pb *testing.PB) {
waterlevel := int(float32(cachesize) * writeradio)
for pb.Next() {
i := int(fastrandn(cachesize))
if i <= cachesize/writepercent {
if i <= waterlevel {
cache.AddWithLifetime(keymap[i], i, time.Hour)
} else {
cache.Get(keymap[i])
Expand All @@ -250,9 +256,10 @@ A Performance result as below. Check [actions][actions] for more results and det
b.ResetTimer()

b.RunParallel(func(pb *testing.PB) {
waterlevel := int(float32(cachesize) * writeradio)
for pb.Next() {
i := int(fastrandn(cachesize))
if i <= cachesize/writepercent {
if i <= waterlevel {
cache.SetWithTTL(keymap[i], i, time.Hour)
} else {
cache.Get(keymap[i])
Expand Down

0 comments on commit 53a77c3

Please sign in to comment.