Add option to use old random and a benchmark

This commit is contained in:
Aria 2025-08-24 11:56:11 -05:00
parent 1e96d59ac8
commit 5d5159a08f
3 changed files with 99 additions and 1 deletions

View file

@ -0,0 +1,46 @@
import { describe, bench } from 'vitest';
import { calculateSteps, rand, useOldRandom } from '../index.mjs';
const testingResolution = 1024;
const _generateRandomPattern = () => rand.iter(testingResolution).fast(testingResolution).firstCycle();
describe('random', () => {
calculateSteps(true);
bench(
'+tactus',
_generateRandomPattern,
{ time: 1000 },
);
calculateSteps(false);
bench(
'-tactus',
_generateRandomPattern,
{ time: 1000 },
);
});
describe('old random', () => {
calculateSteps(true);
bench(
'+tactus',
() => {
useOldRandom();
_generateRandomPattern();
},
{ time: 1000 },
);
calculateSteps(false);
bench(
'-tactus',
() => {
useOldRandom();
_generateRandomPattern();
},
{ time: 1000 },
);
});
calculateSteps(true);