Skip to content

Commit dfc7ba3

Browse files
committed
chore: add node:util to benchmarks
1 parent 2351e50 commit dfc7ba3

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ A 730B library for parsing CLI flags. Inspired by Deno's `std` [`flags`](https:/
66

77
- It's very small.
88
- It's very fast.
9+
- It's a nicer API (and faster!) than [`parseArgs` from `node:util`](https://nodejs.org/api/util.html#utilparseargsconfig).
910

1011
### Usage
1112

@@ -37,8 +38,9 @@ const args = parse(argv, {
3738
## Benchmarks
3839

3940
```
40-
mri x 1,285,159 ops/sec ±0.29% (90 runs sampled)
41-
ultraflag x 986,699 ops/sec ±0.38% (91 runs sampled)
42-
minimist x 250,866 ops/sec ±0.59% (92 runs sampled)
43-
yargs-parser x 18,153 ops/sec ±4.30% (85 runs sampled)
41+
mri x 1,650,986 ops/sec ±0.32% (97 runs sampled)
42+
ultraflag x 1,407,191 ops/sec ±0.38% (99 runs sampled)
43+
minimist x 383,506 ops/sec ±0.28% (99 runs sampled)
44+
node:util x 320,953 ops/sec ±0.35% (98 runs sampled)
45+
yargs-parser x 31,874 ops/sec ±1.32% (92 runs sampled)
4446
```

scripts/bench.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import { parseArgs } from 'node:util'
12
import benchmark from "benchmark";
2-
import { parse as ultraflag } from "../dist/index.js";
33
import minimist from 'minimist';
4-
import yargs from 'yargs-parser';
54
import mri from 'mri';
5+
import yargs from 'yargs-parser';
6+
import { parse as ultraflag } from "../dist/index.js";
67

78
const bench = new benchmark.Suite();
89
const args = ['--a=1', '-b', '--bool', '--no-boop', '--multi=foo', '--multi=baz', '-xyz'];
@@ -11,6 +12,7 @@ bench
1112
.add('ultraflag ', () => ultraflag(args))
1213
.add('mri ', () => mri(args))
1314
.add('minimist ', () => minimist(args))
15+
.add('node:util', () => parseArgs({ args, strict: false, allowNegative: true, options: { bool: { type: 'boolean', short: 'b' }, boop: { type: 'boolean' }, multi: { type: 'string' }} }))
1416
.add('yargs-parser ', () => yargs(args))
1517
.on('cycle', e => console.log(String(e.target)))
1618
.run();

0 commit comments

Comments
 (0)