Skip to content

Commit

Permalink
Changing seed
Browse files Browse the repository at this point in the history
  • Loading branch information
dubzzz committed Nov 5, 2020
1 parent bd9180d commit 4cd8fe8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion perf/benchmark.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ async function run() {
console.info(`${chalk.cyan('INFO ')} Measuring number of calls to next...\n`);
for (const test of performanceTests) {
for (const [type, lib] of configurations) {
const [g, counter] = countCallsToNext(genFor(lib, PROF_GEN));
const [g, counter] = countCallsToNext(genFor(lib, PROF_GEN, 42)); // seed: 42, we always want the same seed
test.run(lib, () => g);
console.log(`${test.name(type)} called generator on next ${counter.count} times`);
}
Expand Down
7 changes: 4 additions & 3 deletions perf/helpers.cjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// @ts-check

let seed = 0;
// Build a generator for
exports.genFor = (lib, genName) => {
const seed = 42;
return lib[genName](seed);
exports.genFor = (lib, genName, askedSeed) => {
seed = (seed + 1) | 0;
return lib[genName](askedSeed || seed);
};

// Build a wrapper around a generator to count calls to next
Expand Down

0 comments on commit 4cd8fe8

Please sign in to comment.