Files
opencode/packages/core/perf/location.bench.ts
2026-11-03 20:05:16 -06:00

45 lines
1.2 KiB
TypeScript

import { bench, script } from "@hona/strobe"
export default bench({
targets: { core: script("./location.ts") },
cases: {
// A request for a directory the server already serves.
"load a cached location": {
primary: "cpu.work",
async run(ctx) {
await ctx.call("load")
},
},
// The first request after the directory's graph was dropped (a config change, an idle eviction).
"load a location": {
primary: "cpu.work",
async run(ctx) {
await ctx.call("load")
},
async reset(ctx) {
await ctx.call("invalidate")
},
},
// What one more open directory keeps alive in a long-running server.
"keep a location graph": {
primary: "js.heap.retained",
metrics: ["cpu.work"],
async run(ctx) {
await ctx.call("keepLocation")
},
},
"keep a models.dev plugin instance": {
primary: "js.heap.retained",
metrics: ["cpu.work"],
async run(ctx) {
await ctx.call("keepPlugin")
},
},
},
async setup(ctx) {
// The first load pays for module and database setup once; a cold case starts dropped.
await ctx.call("load")
if (ctx.case === "load a location") await ctx.call("invalidate")
},
})