initial commit
This commit is contained in:
55
benchmarks/option/conversion.bench.ts
Normal file
55
benchmarks/option/conversion.bench.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { bench, describe } from 'vitest';
|
||||
import { STANDARD } from '../helpers/bench-options.js';
|
||||
import {
|
||||
some,
|
||||
none,
|
||||
OxSome,
|
||||
OxNone,
|
||||
O,
|
||||
pipe,
|
||||
} from '../helpers/imports.js';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// toNullable — Some path
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
describe('Option.toNullable — Some', () => {
|
||||
const nm = some(42);
|
||||
const ox = OxSome(42);
|
||||
const fp = O.some(42);
|
||||
|
||||
bench('native-monad', () => { nm.toNullable(); }, STANDARD);
|
||||
bench('oxide.ts', () => { ox.into(); }, STANDARD);
|
||||
bench('fp-ts', () => { pipe(fp, O.toNullable); }, STANDARD);
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// toNullable — None path
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
describe('Option.toNullable — None', () => {
|
||||
const nm = none();
|
||||
const ox = OxNone;
|
||||
const fp = O.none;
|
||||
|
||||
bench('native-monad', () => { nm.toNullable(); }, STANDARD);
|
||||
bench('oxide.ts', () => { ox.into(); }, STANDARD);
|
||||
bench('fp-ts', () => { pipe(fp, O.toNullable); }, STANDARD);
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// toString
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
describe('Option.toString — Some', () => {
|
||||
const nm = some(42);
|
||||
|
||||
bench('native-monad', () => { nm.toString(); }, STANDARD);
|
||||
// Most other libraries don't have toString
|
||||
});
|
||||
|
||||
describe('Option.toString — None', () => {
|
||||
const nm = none();
|
||||
|
||||
bench('native-monad', () => { nm.toString(); }, STANDARD);
|
||||
});
|
||||
Reference in New Issue
Block a user