overtake 0.0.3 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -0
- package/cli.js +2 -17
- package/index.js +22 -18
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -38,6 +38,8 @@ $ npm install -D overtake
|
|
|
38
38
|
|
|
39
39
|
## Examples
|
|
40
40
|
|
|
41
|
+
### Public interface
|
|
42
|
+
|
|
41
43
|
Create a benchmark in `__benchmarks__` folder
|
|
42
44
|
|
|
43
45
|
```javascript
|
|
@@ -91,6 +93,36 @@ or
|
|
|
91
93
|
npx overtake
|
|
92
94
|
```
|
|
93
95
|
|
|
96
|
+
### Inline support
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
npx overtake -i "class A{}" -i "function A() {}" -i "A = () => {};" -c 20000
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
⭐ Script
|
|
104
|
+
⇶ Suite
|
|
105
|
+
➤ Perform
|
|
106
|
+
✓ Measure class A{}
|
|
107
|
+
┌─────────┬──────────┬──────────┬──────────┬───────────┬───────┐
|
|
108
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
109
|
+
├─────────┼──────────┼──────────┼──────────┼───────────┼───────┤
|
|
110
|
+
│ 0.0005 │ 0.000551 │ 0.001493 │ 0.002344 │ 16.506385 │ 20000 │
|
|
111
|
+
└─────────┴──────────┴──────────┴──────────┴───────────┴───────┘
|
|
112
|
+
✓ Measure function A() {}
|
|
113
|
+
┌─────────┬─────────┬────────┬──────────┬──────────┬───────┐
|
|
114
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
115
|
+
├─────────┼─────────┼────────┼──────────┼──────────┼───────┤
|
|
116
|
+
│ 0.00008 │ 0.00009 │ 0.0003 │ 0.000441 │ 2.875578 │ 20000 │
|
|
117
|
+
└─────────┴─────────┴────────┴──────────┴──────────┴───────┘
|
|
118
|
+
✓ Measure A = () => {};
|
|
119
|
+
┌─────────┬─────────┬──────────┬──────────┬─────────┬───────┐
|
|
120
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
121
|
+
├─────────┼─────────┼──────────┼──────────┼─────────┼───────┤
|
|
122
|
+
│ 0.00008 │ 0.00012 │ 0.000331 │ 0.000601 │ 3.42556 │ 20000 │
|
|
123
|
+
└─────────┴─────────┴──────────┴──────────┴─────────┴───────┘
|
|
124
|
+
```
|
|
125
|
+
|
|
94
126
|
Please take a look at [benchmarks](__benchmarks__) to see more examples
|
|
95
127
|
|
|
96
128
|
## License
|
package/cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env -S node --no-warnings
|
|
2
2
|
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
import { promisify } from 'util';
|
|
@@ -15,7 +15,7 @@ commands
|
|
|
15
15
|
.argument('[files...]', 'file paths or path patterns to search benchmark scripts')
|
|
16
16
|
.option('-i, --inline [inline]', 'inline code to benchmark', (value, previous) => previous.concat([value]), [])
|
|
17
17
|
.option('-c, --count [count]', 'perform count for inline code', (v) => parseInt(v))
|
|
18
|
-
.action(async (patterns, { count =
|
|
18
|
+
.action(async (patterns, { count = 1, inline }) => {
|
|
19
19
|
Object.assign(globalThis, { benchmark, setup, teardown, measure, perform });
|
|
20
20
|
|
|
21
21
|
const globAsync = promisify(glob);
|
|
@@ -60,18 +60,3 @@ commands.on('--help', () => {
|
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
commands.parse(process.argv);
|
|
63
|
-
|
|
64
|
-
//
|
|
65
|
-
|
|
66
|
-
//
|
|
67
|
-
// (async () => {
|
|
68
|
-
// const files = await globAsync(pattern);
|
|
69
|
-
// const scripts = [];
|
|
70
|
-
// for (const file of files) {
|
|
71
|
-
// const filename = Path.resolve(file);
|
|
72
|
-
// const script = await load(filename);
|
|
73
|
-
// scripts.push(script);
|
|
74
|
-
// }
|
|
75
|
-
//
|
|
76
|
-
// await run(scripts, defaultReporter);
|
|
77
|
-
// })().catch((e) => console.error(e));
|
package/index.js
CHANGED
|
@@ -59,7 +59,27 @@ const map = {
|
|
|
59
59
|
|
|
60
60
|
export const defaultReporter = async (type, title, test) => {
|
|
61
61
|
console.group(`${map[type]} ${title}`);
|
|
62
|
-
await test({
|
|
62
|
+
await test({
|
|
63
|
+
test: defaultReporter,
|
|
64
|
+
output: (report) =>
|
|
65
|
+
console.table(
|
|
66
|
+
report.success
|
|
67
|
+
? {
|
|
68
|
+
[formatFloat(report.mode)]: {
|
|
69
|
+
med: formatFloat(report.med),
|
|
70
|
+
p95: formatFloat(report.p95),
|
|
71
|
+
p99: formatFloat(report.p99),
|
|
72
|
+
total: formatFloat(report.sum),
|
|
73
|
+
count: report.count,
|
|
74
|
+
},
|
|
75
|
+
}
|
|
76
|
+
: {
|
|
77
|
+
error: {
|
|
78
|
+
reason: report.error,
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
});
|
|
63
83
|
console.groupEnd();
|
|
64
84
|
};
|
|
65
85
|
|
|
@@ -85,23 +105,7 @@ export const run = async (scripts, reporter) => {
|
|
|
85
105
|
count: perform.count,
|
|
86
106
|
args: perform.args,
|
|
87
107
|
});
|
|
88
|
-
|
|
89
|
-
measureTest.output({
|
|
90
|
-
[formatFloat(result.mode)]: {
|
|
91
|
-
total: formatFloat(result.total),
|
|
92
|
-
med: formatFloat(result.med),
|
|
93
|
-
p95: formatFloat(result.p95),
|
|
94
|
-
p99: formatFloat(result.p99),
|
|
95
|
-
count: result.count,
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
|
-
} else {
|
|
99
|
-
measureTest.output({
|
|
100
|
-
error: {
|
|
101
|
-
reason: result.error,
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
}
|
|
108
|
+
measureTest.output(result);
|
|
105
109
|
});
|
|
106
110
|
}
|
|
107
111
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "overtake",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "NodeJS performance benchmark",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"overtake": "cli.js"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
|
-
"start": "
|
|
12
|
+
"start": "./cli.js",
|
|
13
13
|
"test": "yarn node --experimental-vm-modules $(yarn bin jest) --detectOpenHandles",
|
|
14
14
|
"lint": "eslint .",
|
|
15
15
|
"prepare": "husky install"
|