-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbenchmark.js
More file actions
81 lines (67 loc) · 1.82 KB
/
benchmark.js
File metadata and controls
81 lines (67 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env node
/**
* Main benchmark runner that executes all performance tests
*/
import { spawn } from "node:child_process";
import { fileURLToPath } from "node:url";
import { dirname, join } from "node:path";
const __dirname = dirname(fileURLToPath(import.meta.url));
const benchmarksDir = join(__dirname, "benchmarks");
const benchmarks = [
"auth.js",
"basic-http.js",
"hypermedia.js",
"load-test.js",
"memory.js",
"parsers.js",
"rate-limiting.js",
"renderers.js",
"serializers.js"
];
/**
* Runs a single benchmark file
* @param {string} file - The benchmark file to run
* @returns {Promise<void>}
*/
function runBenchmark (file) {
return new Promise((resolve, reject) => {
console.log(`\n${"=".repeat(60)}`);
console.log(`Running benchmark: ${file}`);
console.log(`${"=".repeat(60)}`);
const child = spawn("node", [join(benchmarksDir, file)], {
stdio: "inherit",
cwd: benchmarksDir
});
child.on("close", code => {
if (code === 0) {
resolve();
} else {
reject(new Error(`Benchmark ${file} failed with exit code ${code}`));
}
});
child.on("error", reject);
});
}
/**
* Main execution function
*/
async function main () {
console.log("🚀 Starting Tenso Framework Benchmarks");
console.log(`Node.js version: ${process.version}`);
console.log(`Platform: ${process.platform}`);
console.log(`Architecture: ${process.arch}`);
const startTime = Date.now();
try {
for (const benchmark of benchmarks) {
await runBenchmark(benchmark);
}
const duration = ((Date.now() - startTime) / 1000).toFixed(2);
console.log(`\n${"=".repeat(60)}`);
console.log(`✅ All benchmarks completed in ${duration}s`);
console.log(`${"=".repeat(60)}`);
} catch (error) {
console.error(`\n❌ Benchmark suite failed: ${error.message}`);
process.exit(1);
}
}
main().catch(console.error);