Compare commits
4 Commits
Author | SHA1 | Date |
---|---|---|
|
46f4078530 | |
|
8026b575a9 | |
|
5633e08626 | |
|
9f6ff22cff |
2
LICENSE
2
LICENSE
|
@ -1,4 +1,4 @@
|
||||||
Copyright (c) 2012-2017 Patrick Mylund Nielsen and the go-cache contributors
|
Copyright (c) 2012-2019 Patrick Mylund Nielsen and the go-cache contributors
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
|
@ -1555,7 +1555,7 @@ func benchmarkCacheGetManyConcurrent(b *testing.B, exp time.Duration) {
|
||||||
tc := New(exp, 0)
|
tc := New(exp, 0)
|
||||||
keys := make([]string, n)
|
keys := make([]string, n)
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
k := "foo" + strconv.Itoa(n)
|
k := "foo" + strconv.Itoa(i)
|
||||||
keys[i] = k
|
keys[i] = k
|
||||||
tc.Set(k, "bar", DefaultExpiration)
|
tc.Set(k, "bar", DefaultExpiration)
|
||||||
}
|
}
|
||||||
|
@ -1563,12 +1563,12 @@ func benchmarkCacheGetManyConcurrent(b *testing.B, exp time.Duration) {
|
||||||
wg := new(sync.WaitGroup)
|
wg := new(sync.WaitGroup)
|
||||||
wg.Add(n)
|
wg.Add(n)
|
||||||
for _, v := range keys {
|
for _, v := range keys {
|
||||||
go func() {
|
go func(k string) {
|
||||||
for j := 0; j < each; j++ {
|
for j := 0; j < each; j++ {
|
||||||
tc.Get(v)
|
tc.Get(k)
|
||||||
}
|
}
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}()
|
}(v)
|
||||||
}
|
}
|
||||||
b.StartTimer()
|
b.StartTimer()
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
|
@ -65,7 +65,7 @@ func benchmarkShardedCacheGetManyConcurrent(b *testing.B, exp time.Duration) {
|
||||||
tsc := unexportedNewSharded(exp, 0, 20)
|
tsc := unexportedNewSharded(exp, 0, 20)
|
||||||
keys := make([]string, n)
|
keys := make([]string, n)
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
k := "foo" + strconv.Itoa(n)
|
k := "foo" + strconv.Itoa(i)
|
||||||
keys[i] = k
|
keys[i] = k
|
||||||
tsc.Set(k, "bar", DefaultExpiration)
|
tsc.Set(k, "bar", DefaultExpiration)
|
||||||
}
|
}
|
||||||
|
@ -73,12 +73,12 @@ func benchmarkShardedCacheGetManyConcurrent(b *testing.B, exp time.Duration) {
|
||||||
wg := new(sync.WaitGroup)
|
wg := new(sync.WaitGroup)
|
||||||
wg.Add(n)
|
wg.Add(n)
|
||||||
for _, v := range keys {
|
for _, v := range keys {
|
||||||
go func() {
|
go func(k string) {
|
||||||
for j := 0; j < each; j++ {
|
for j := 0; j < each; j++ {
|
||||||
tsc.Get(v)
|
tsc.Get(k)
|
||||||
}
|
}
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}()
|
}(v)
|
||||||
}
|
}
|
||||||
b.StartTimer()
|
b.StartTimer()
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
Loading…
Reference in New Issue