Skip to content

Commit

Permalink
Add warmup and increase iterations
Browse files Browse the repository at this point in the history
  • Loading branch information
hansott committed Jan 17, 2025
1 parent c1321e2 commit 75e434e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
7 changes: 6 additions & 1 deletion benchmarks/operations/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const modules = [
console.log(`Running module ${module}`);
const withoutZen = spawnSync(`node`, ["run.js", module, "false"], {
cwd: __dirname,
maxBuffer: 1024 * 1024 * 1024,
});

if (withoutZen.status !== 0) {
Expand All @@ -74,6 +75,7 @@ const modules = [

const withZen = spawnSync("node", ["run.js", module, "true"], {
cwd: __dirname,
maxBuffer: 1024 * 1024 * 1024,
});

if (withZen.status !== 0) {
Expand Down Expand Up @@ -105,7 +107,10 @@ const modules = [
console.log(
`Average time with Zen: ${formatter.format(averageWithZen)}ms`
);
console.log(`Delta: +${formatter.format(delta)}ms`);
const deltaFormatted = formatter.format(delta).startsWith("-")
? formatter.format(delta)
: `+${formatter.format(delta)}`;
console.log(`Delta: ${deltaFormatted}ms`);

markdownTable += `| ${name} | ${formatter.format(averageWithoutZen)}ms | ${formatter.format(averageWithZen)}ms | +${formatter.format(delta)}ms |\n`;
}
Expand Down
9 changes: 6 additions & 3 deletions benchmarks/operations/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ const mod = require(`./${process.argv[2]}`);
process.exit(1);
}

const timings = [];
const amount = 1000;
// Warmup
for (let i = 0; i < 2000; i++) {
await mod.step();
}

const timings = [];
async function steps() {
for (let i = 0; i < amount; i++) {
for (let i = 0; i < 20000; i++) {
const start = performance.now();
await mod.step();
const end = performance.now();
Expand Down
12 changes: 10 additions & 2 deletions benchmarks/operations/shelli.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
const { execSync } = require("child_process");
const { exec } = require("child_process");

module.exports = {
step: async function step() {
execSync("ls -la");
return new Promise((resolve, reject) => {
exec("echo", { cwd: __dirname }, (err) => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
},
};

0 comments on commit 75e434e

Please sign in to comment.