xen-dev-utils
Version:
Utility functions used by the Scale Workshop ecosystem
51 lines • 1.85 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
// It's important to use the distributed versions for a realistic comparison
const legacy_1 = require("../../legacy/legacy");
const monzo_1 = require("../monzo");
function randInt() {
return Math.ceil(Math.random() * 1000000000);
}
function randNumComponents() {
return 2 + Math.floor(Math.random() * 10);
}
(0, vitest_1.describe)('Number to prime exponent vector conversion', () => {
(0, vitest_1.bench)('Old implementation', () => {
try {
(0, legacy_1.toMonzoLegacy)(randInt());
}
catch { }
});
(0, vitest_1.bench)('Using probes without division', () => {
try {
(0, monzo_1.toMonzo)(randInt());
}
catch { }
});
});
(0, vitest_1.describe)('Prime limit calculator', () => {
(0, vitest_1.bench)('Old implementation', () => {
(0, legacy_1.primeLimitLegacy)(randInt());
});
(0, vitest_1.bench)('New implementation', () => {
(0, monzo_1.primeLimit)(randInt());
});
});
(0, vitest_1.describe)('Monzo with residual', () => {
(0, vitest_1.bench)('Current implementation', () => {
(0, monzo_1.toMonzoAndResidual)(randInt(), randNumComponents());
});
(0, vitest_1.bench)('Old implementation', () => {
(0, legacy_1.toMonzoAndResidualLegacy)(randInt(), randNumComponents());
});
});
(0, vitest_1.describe)('Monzo with residual (bigint)', () => {
(0, vitest_1.bench)('Current implementation', () => {
(0, monzo_1.toMonzoAndResidual)(BigInt(randInt()), randNumComponents());
});
(0, vitest_1.bench)('Old implementation', () => {
(0, legacy_1.toMonzoAndResidualLegacy)(BigInt(randInt()), randNumComponents());
});
});
//# sourceMappingURL=monzo.bench.js.map