Benchmarks (#1079)

* tactus-oriented benchmarks
* add benchmarks for individual example tunes
This commit is contained in:
Alex McLean 2024-05-03 10:52:56 +01:00 committed by GitHub
parent 8e2d883e86
commit e47d67a9da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 96 additions and 0 deletions

View file

@ -0,0 +1,46 @@
import { describe, bench } from 'vitest';
import { calculateTactus, sequence, stack } from '../index.mjs';
const pat64 = sequence(...Array(64).keys());
describe('tactus', () => {
calculateTactus(true);
bench(
'+tactus',
() => {
pat64.iter(64).fast(64).firstCycle();
},
{ time: 1000 },
);
calculateTactus(false);
bench(
'-tactus',
() => {
pat64.iter(64).fast(64).firstCycle();
},
{ time: 1000 },
);
});
describe('stack', () => {
calculateTactus(true);
bench(
'+tactus',
() => {
stack(pat64, pat64, pat64, pat64, pat64, pat64, pat64, pat64).fast(64).firstCycle();
},
{ time: 1000 },
);
calculateTactus(false);
bench(
'-tactus',
() => {
stack(pat64, pat64, pat64, pat64, pat64, pat64, pat64, pat64).fast(64).firstCycle();
},
{ time: 1000 },
);
});
calculateTactus(true);

View file

@ -9,6 +9,7 @@
},
"scripts": {
"test": "vitest run",
"bench": "vitest bench",
"build": "vite build",
"prepublishOnly": "pnpm build"
},

View file

@ -0,0 +1,25 @@
import { describe, bench } from 'vitest';
import { calculateTactus } from '../../core/index.mjs';
import { mini } from '../index.mjs';
describe('mini', () => {
calculateTactus(true);
bench(
'+tactus',
() => {
mini('a b c*3 [c d e, f g] <a b [c d?]>').fast(64).firstCycle();
},
{ time: 1000 },
);
calculateTactus(false);
bench(
'-tactus',
() => {
mini('a b c*3 [c d e, f g] <a b [c d?]>').fast(64).firstCycle();
},
{ time: 1000 },
);
calculateTactus(true);
});

View file

@ -9,6 +9,7 @@
},
"scripts": {
"test": "vitest run",
"bench": "vitest bench",
"build:parser": "peggy -o krill-parser.js --format es ./krill.pegjs",
"build": "vite build",
"prepublishOnly": "npm run build"