initial commit
This commit is contained in:
25
benchmarks/helpers/bench-options.ts
Normal file
25
benchmarks/helpers/bench-options.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import type { BenchOptions } from 'vitest';
|
||||
|
||||
/** Standard options for most benchmarks — 500ms run time, 100 min iterations */
|
||||
export const STANDARD: BenchOptions = {
|
||||
time: 500,
|
||||
iterations: 100,
|
||||
warmupTime: 100,
|
||||
warmupIterations: 5,
|
||||
};
|
||||
|
||||
/** Extended options for async/expensive benchmarks — 1s run time */
|
||||
export const EXTENDED: BenchOptions = {
|
||||
time: 1000,
|
||||
iterations: 25,
|
||||
warmupTime: 250,
|
||||
warmupIterations: 3,
|
||||
};
|
||||
|
||||
/** Quick options for allocation/memory pattern benchmarks */
|
||||
export const QUICK: BenchOptions = {
|
||||
time: 250,
|
||||
iterations: 500,
|
||||
warmupTime: 50,
|
||||
warmupIterations: 10,
|
||||
};
|
||||
22
benchmarks/helpers/data-generators.ts
Normal file
22
benchmarks/helpers/data-generators.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
export const SIZES = [100, 10_000] as const;
|
||||
|
||||
export function generateNumbers(size: number): number[] {
|
||||
return Array.from({ length: size }, (_, i) => i);
|
||||
}
|
||||
|
||||
export function generateStrings(size: number): string[] {
|
||||
return Array.from({ length: size }, (_, i) => `item-${i}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates indices that should be "error" slots, deterministically distributed.
|
||||
* With errRatio=0.2 and size=10, returns indices [4, 9] (every 5th element).
|
||||
*/
|
||||
export function errorIndices(size: number, errRatio = 0.2): Set<number> {
|
||||
const step = Math.max(1, Math.floor(1 / errRatio));
|
||||
const indices = new Set<number>();
|
||||
for (let i = step - 1; i < size; i += step) {
|
||||
indices.add(i);
|
||||
}
|
||||
return indices;
|
||||
}
|
||||
53
benchmarks/helpers/imports.ts
Normal file
53
benchmarks/helpers/imports.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
// native-monad
|
||||
export {
|
||||
ok,
|
||||
err,
|
||||
some,
|
||||
none,
|
||||
okSome,
|
||||
okNone,
|
||||
errNone,
|
||||
Result,
|
||||
Option,
|
||||
Query,
|
||||
ResultPromise,
|
||||
OptionPromise,
|
||||
QueryPromise,
|
||||
} from 'native-monad';
|
||||
|
||||
// neverthrow
|
||||
export {
|
||||
ok as ntOk,
|
||||
err as ntErr,
|
||||
Result as NtResult,
|
||||
ResultAsync as NtResultAsync,
|
||||
fromThrowable as ntFromThrowable,
|
||||
} from 'neverthrow';
|
||||
|
||||
// ts-results-es
|
||||
export {
|
||||
Ok as TsOk,
|
||||
Err as TsErr,
|
||||
Some as TsSome,
|
||||
None as TsNone,
|
||||
Result as TsResult,
|
||||
Option as TsOption,
|
||||
} from 'ts-results-es';
|
||||
|
||||
// oxide.ts
|
||||
export {
|
||||
Ok as OxOk,
|
||||
Err as OxErr,
|
||||
Some as OxSome,
|
||||
None as OxNone,
|
||||
match as oxMatch,
|
||||
} from 'oxide.ts';
|
||||
|
||||
// fp-ts
|
||||
export * as E from 'fp-ts/Either';
|
||||
export * as O from 'fp-ts/Option';
|
||||
export { pipe } from 'fp-ts/function';
|
||||
|
||||
// true-myth (static functions are named exports, not on default)
|
||||
export * as TmResult from 'true-myth/result';
|
||||
export * as TmMaybe from 'true-myth/maybe';
|
||||
Reference in New Issue
Block a user