mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-11 05:38:34 +00:00
Benchmarks (#1079)
* tactus-oriented benchmarks * add benchmarks for individual example tunes
This commit is contained in:
parent
8e2d883e86
commit
e47d67a9da
22
bench/tunes.bench.mjs
Normal file
22
bench/tunes.bench.mjs
Normal file
@ -0,0 +1,22 @@
|
||||
import { queryCode, testCycles } from '../test/runtime.mjs';
|
||||
import * as tunes from '../website/src/repl/tunes.mjs';
|
||||
import { describe, bench } from 'vitest';
|
||||
import { calculateTactus } from '../packages/core/index.mjs';
|
||||
|
||||
const tuneKeys = Object.keys(tunes);
|
||||
|
||||
describe('renders tunes', () => {
|
||||
tuneKeys.forEach((key) => {
|
||||
describe(key, () => {
|
||||
calculateTactus(true);
|
||||
bench(`+tactus`, async () => {
|
||||
await queryCode(tunes[key], testCycles[key] || 1);
|
||||
});
|
||||
calculateTactus(false);
|
||||
bench(`-tactus`, async () => {
|
||||
await queryCode(tunes[key], testCycles[key] || 1);
|
||||
});
|
||||
calculateTactus(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -11,6 +11,7 @@
|
||||
"test": "npm run pretest && vitest run --version",
|
||||
"test-ui": "npm run pretest && vitest --ui",
|
||||
"test-coverage": "npm run pretest && vitest --coverage",
|
||||
"bench": "npm run pretest && vitest bench",
|
||||
"snapshot": "npm run pretest && vitest run -u --silent",
|
||||
"repl": "npm run prestart && cd website && npm run dev",
|
||||
"start": "npm run prestart && cd website && npm run dev",
|
||||
|
||||
46
packages/core/bench/pattern.bench.mjs
Normal file
46
packages/core/bench/pattern.bench.mjs
Normal 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);
|
||||
@ -9,6 +9,7 @@
|
||||
},
|
||||
"scripts": {
|
||||
"test": "vitest run",
|
||||
"bench": "vitest bench",
|
||||
"build": "vite build",
|
||||
"prepublishOnly": "pnpm build"
|
||||
},
|
||||
|
||||
25
packages/mini/bench/mini.bench.mjs
Normal file
25
packages/mini/bench/mini.bench.mjs
Normal 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);
|
||||
});
|
||||
@ -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"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user