Skip to content

Commit

Permalink
feat: expose the v8 flags from @codspeed/core
Browse files Browse the repository at this point in the history
  • Loading branch information
art049 committed Jun 27, 2023
1 parent a2d0d88 commit 7a97506
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,21 @@ export const optimizeFunctionSync = (fn: CallableFunction) => {
eval("%OptimizeFunctionOnNextCall(fn)");
fn(); // optimize
};

export const getV8Flags = (majorVersion: string): string => {
const major = parseInt(majorVersion);
const flags = [
"--hash-seed=1",
"--random-seed=1",
"--no-opt",
"--predictable",
"--predictable-gc-schedule",
];
if (major < 18) {
flags.push("--no-randomize-hashes");
}
if (major < 20) {
flags.push("--no-scavenge-task");
}
return flags.join(" ");
};

0 comments on commit 7a97506

Please sign in to comment.