mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-11-26 10:06:31 +00:00
test(yaegi-bench): time a 1,600-key getMulti
The admin usage path reads up to 1,600 keys per round trip. The bench now reports this cost so the admin-path gain is visible.
This commit is contained in:
@@ -34,6 +34,8 @@ var (
|
||||
benchLoop *sharedStateLoop
|
||||
benchAll []string
|
||||
benchVals []int64
|
||||
benchStore counterStore
|
||||
benchBig []string
|
||||
)
|
||||
|
||||
func BenchRefreshSetup(redisAddr string, n int) int {
|
||||
@@ -53,6 +55,16 @@ func BenchRefreshSetup(redisAddr string, n int) int {
|
||||
newSharedBreaker(l, sharedKindDiscovery, ids, 5, time.Second, time.Minute, 2*time.Minute)
|
||||
newSharedBreaker(l, sharedKindDecision, ids, 5, time.Second, time.Minute, 2*time.Minute)
|
||||
benchLoop = l
|
||||
benchStore = store
|
||||
benchBig = make([]string, usageModelsChunkKeys)
|
||||
bigEntries := make([]counterIncr, len(benchBig))
|
||||
for i := range benchBig {
|
||||
benchBig[i] = "bench-big-" + strconv.Itoa(i)
|
||||
bigEntries[i] = counterIncr{key: benchBig[i], delta: int64(i%%5 + 1), ttl: time.Hour, enforceTTL: time.Hour}
|
||||
}
|
||||
if _, err := store.incrMulti(bigEntries); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
now := time.Now()
|
||||
benchAll = nil
|
||||
for _, p := range l.snapshot() {
|
||||
@@ -115,6 +127,15 @@ func BenchGetMultiRun(n int) int {
|
||||
return sum
|
||||
}
|
||||
|
||||
func BenchGetMulti1600Run(n int) int {
|
||||
sum := 0
|
||||
for i := 0; i < n; i++ {
|
||||
got, _ := benchStore.getMulti(benchBig)
|
||||
sum += len(got)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
func BenchApplyRun(n int) {
|
||||
prims := benchLoop.snapshot()
|
||||
sizes := make([]int, len(prims))
|
||||
@@ -257,7 +278,7 @@ func runRefresh(root, redisAddr string, samples int) error {
|
||||
}
|
||||
add(o.name, f.(func(int)))
|
||||
}
|
||||
for _, o := range []struct{ name, sym string }{{"keys", "BenchKeysRun"}, {"getmulti", "BenchGetMultiRun"}} {
|
||||
for _, o := range []struct{ name, sym string }{{"keys", "BenchKeysRun"}, {"getmulti", "BenchGetMultiRun"}, {"getmulti1600", "BenchGetMulti1600Run"}} {
|
||||
f, e := get(o.sym)
|
||||
if e != nil {
|
||||
return e
|
||||
|
||||
Reference in New Issue
Block a user