Skip to content

Commit

Permalink
add bench
Browse files Browse the repository at this point in the history
  • Loading branch information
jbolda committed Jun 7, 2024
1 parent 2e953b4 commit 6ed87f6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/foundation/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,14 @@ export async function createFoundationSimulationServer<
});
}

return server;
return {
...server,
ensureClose: () =>
new Promise<void>((resolve) => {
server.once("close", resolve);
server.close();
}),
};
},
};
}
Expand Down
17 changes: 17 additions & 0 deletions packages/foundation/tests/examples.bench.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { bench, describe } from "vitest";
import { simulation as singleFileSimulation } from "../example/singleFileServer";
import { simulation as extensiveSimulation } from "../example/extensiveServer";

describe("server start and close", () => {
bench("single file server", async () => {
let app = await singleFileSimulation;
let server = await app.listen();
await server.ensureClose();
});

bench("extensive server", async () => {
let app = await extensiveSimulation;
let server = await app.listen();
await server.ensureClose();
});
});

0 comments on commit 6ed87f6

Please sign in to comment.