summaryrefslogtreecommitdiff
path: root/benchmark/packages/timer/src/server.ts
diff options
context:
space:
mode:
authorGravatar Bjorn Lu <bjornlu.dev@gmail.com> 2023-03-07 10:52:47 +0800
committerGravatar GitHub <noreply@github.com> 2023-03-07 10:52:47 +0800
commit00a0af7ed44f5bb275f570ca38bbd0b798ce84ad (patch)
tree4c15d9223bffbcd4999a1950580cbd3a02a8ae5f /benchmark/packages/timer/src/server.ts
parentaf05a4fa4637bad9b20b9928e6d2c2f894aa9139 (diff)
downloadastro-00a0af7ed44f5bb275f570ca38bbd0b798ce84ad.tar.gz
astro-00a0af7ed44f5bb275f570ca38bbd0b798ce84ad.tar.zst
astro-00a0af7ed44f5bb275f570ca38bbd0b798ce84ad.zip
Move benchmark package and update changeset config (#6433)
Diffstat (limited to 'benchmark/packages/timer/src/server.ts')
-rw-r--r--benchmark/packages/timer/src/server.ts21
1 files changed, 21 insertions, 0 deletions
diff --git a/benchmark/packages/timer/src/server.ts b/benchmark/packages/timer/src/server.ts
new file mode 100644
index 000000000..5cfa4ad76
--- /dev/null
+++ b/benchmark/packages/timer/src/server.ts
@@ -0,0 +1,21 @@
+import { polyfill } from '@astrojs/webapi';
+import type { SSRManifest } from 'astro';
+import { NodeApp } from 'astro/app/node';
+import type { IncomingMessage, ServerResponse } from 'http';
+
+polyfill(globalThis, {
+ exclude: 'window document',
+});
+
+export function createExports(manifest: SSRManifest) {
+ const app = new NodeApp(manifest);
+ return {
+ handler: async (req: IncomingMessage, res: ServerResponse) => {
+ const start = performance.now();
+ await app.render(req);
+ const end = performance.now();
+ res.write(end - start + '');
+ res.end();
+ },
+ };
+}