Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate benchmarks to vitest bench #23

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
benchmarks/
legacy/
dist/
docs/
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,5 @@ dist
# TypeDoc
docs

# Benchmark
benchmarks
# Compiled legacy artifacts
legacy
1,451 changes: 628 additions & 823 deletions package-lock.json

Large diffs are not rendered by default.

23 changes: 9 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@
],
"types": "dist/index.d.ts",
"devDependencies": {
"@types/benchmark": "^2.1.5",
"@types/node": "^20.10.1",
"benchmark": "^2.1.4",
"gts": "^5.2.0",
"typedoc": "^0.25.4",
"typescript": "^5.3.2",
"vitest": "^0.34.6"
"@types/node": "^20.12.7",
"gts": "^5.3.0",
"typedoc": "^0.25.13",
"typescript": "^5.4.5",
"vitest": "^1.5.0"
},
"scripts": {
"lint": "gts lint",
Expand All @@ -44,13 +42,10 @@
"pretest": "npm run compile",
"posttest": "npm run lint",
"test": "vitest",
"doc": "typedoc src/index.ts . --name xen-dev-utils",
"premonzo-benchmark": "tsc -p tsconfig-benchmark.json",
"monzo-benchmark": "node benchmarks/__benchmarks__/monzo.mark.js",
"preprimes-benchmark": "tsc -p tsconfig-benchmark.json",
"primes-benchmark": "node benchmarks/__benchmarks__/primes.mark.js",
"prefraction-benchmark": "tsc -p tsconfig-benchmark.json",
"fraction-benchmark": "node benchmarks/__benchmarks__/fraction.mark.js"
"compile-legacy": "tsc -p tsconfig-legacy.json",
"prebench": "npm run compile && npm run compile-legacy",
"bench": "vitest bench",
"doc": "typedoc src/index.ts . --name xen-dev-utils"
},
"engines": {
"node": ">=10.6.0"
Expand Down
48 changes: 0 additions & 48 deletions src/__benchmarks__/fraction.mark.ts

This file was deleted.

33 changes: 33 additions & 0 deletions src/__benchmarks__/monzo.bench.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {describe, bench} from 'vitest';

// It's important to use the distributed versions for a realistic comparison
import {toMonzoLegacy, primeLimitLegacy} from '../../legacy/legacy';
import {toMonzo, primeLimit} from '../../dist';

function randInt() {
return Math.ceil(Math.random() * 1000000000);
}

describe('Number to prime exponent vector conversion', () => {
bench('Old implementation', () => {
try {
toMonzoLegacy(randInt());
} catch {}
});

bench('Using probes without division', () => {
try {
toMonzo(randInt());
} catch {}
});
});

describe('Prime limit calculator', () => {
bench('Old implementation', () => {
primeLimitLegacy(randInt());
});

bench('New implementation', () => {
primeLimit(randInt());
});
});
174 changes: 0 additions & 174 deletions src/__benchmarks__/monzo.mark.ts

This file was deleted.

41 changes: 0 additions & 41 deletions src/__benchmarks__/primes.mark.ts

This file was deleted.

Loading
Loading