mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-14 03:56:55 +03:00
45 lines
1.2 KiB
TypeScript
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")
|
|
},
|
|
})
|