overtake 0.0.7 → 0.1.1
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 +10 -0
- package/cli.js +21 -8
- package/index.js +62 -33
- package/overtakes/array-copy.md +80 -0
- package/overtakes/array-delete-element.md +44 -0
- package/overtakes/async.md +25 -0
- package/overtakes/class-vs-function.md +31 -0
- package/overtakes/postgres-vs-mongo.md +55 -0
- package/package.json +11 -9
package/README.md
CHANGED
|
@@ -14,6 +14,7 @@ Performance benchmark for NodeJS
|
|
|
14
14
|
- [Features](#features)
|
|
15
15
|
- [Installing](#installing)
|
|
16
16
|
- [Examples](#examples)
|
|
17
|
+
- [Showcase](#showcase)
|
|
17
18
|
- [License](#license)
|
|
18
19
|
|
|
19
20
|
## Features
|
|
@@ -125,6 +126,15 @@ npx overtake -i "class A{}" -i "function A() {}" -i "A = () => {};" -c 20000
|
|
|
125
126
|
|
|
126
127
|
Please take a look at [benchmarks](__benchmarks__) to see more examples
|
|
127
128
|
|
|
129
|
+
## Showcase
|
|
130
|
+
|
|
131
|
+
Already measured performance
|
|
132
|
+
|
|
133
|
+
- [Class vs Function](./overtakes/class-vs-function.md)
|
|
134
|
+
- [Postgres vs MongoDB](./overtakes/postgres-vs-mongo.md)
|
|
135
|
+
- [Array Copy](./overtakes/array-copy.md)
|
|
136
|
+
- [Array Delete Element](./overtakes/array-delete-element.md)
|
|
137
|
+
|
|
128
138
|
## License
|
|
129
139
|
|
|
130
140
|
License [Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
package/cli.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env -S node --no-warnings
|
|
2
2
|
|
|
3
|
-
import { Command } from 'commander';
|
|
3
|
+
import { Command, Option } from 'commander';
|
|
4
4
|
import Path from 'path';
|
|
5
|
-
import glob from 'glob';
|
|
6
|
-
import { load, createScript, benchmark, setup, teardown, measure, perform, run, defaultReporter } from './index.js';
|
|
5
|
+
import { glob } from 'glob';
|
|
6
|
+
import { load, createScript, benchmark, setup, teardown, measure, perform, run, defaultReporter, allowedFields } from './index.js';
|
|
7
7
|
import packageJson from './package.json' assert { type: 'json' };
|
|
8
8
|
|
|
9
9
|
const commands = new Command();
|
|
@@ -11,10 +11,23 @@ const commands = new Command();
|
|
|
11
11
|
commands.name('overtake').description(packageJson.description).version(packageJson.version, '-v, --version');
|
|
12
12
|
|
|
13
13
|
commands
|
|
14
|
-
.argument('[files...]', '
|
|
15
|
-
.option('-i, --inline [inline]', '
|
|
16
|
-
.option('-c, --count [count]', '
|
|
17
|
-
.
|
|
14
|
+
.argument('[files...]', 'File paths or path patterns to search benchmark scripts')
|
|
15
|
+
.option('-i, --inline [inline]', 'Inline benchmark.', (value, previous) => previous.concat([value]), [])
|
|
16
|
+
.option('-c, --count [count]', 'Perform count for inline benchmark.', (v) => parseInt(v))
|
|
17
|
+
.addOption(
|
|
18
|
+
new Option('-f, --fields [fields]', `Comma separated list of fields to report. Allowed values are: ${allowedFields}.`)
|
|
19
|
+
.default(['med', 'p95', 'p99', 'sum:total', 'count'])
|
|
20
|
+
.argParser((fields) =>
|
|
21
|
+
fields.split(',').filter((field) => {
|
|
22
|
+
if (!allowedFields.includes(field)) {
|
|
23
|
+
console.error(`Invalid field name: ${field}. Allowed values are: ${allowedFields.join(', ')}.`);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}),
|
|
28
|
+
),
|
|
29
|
+
)
|
|
30
|
+
.action(async (patterns, { count = 1, inline, fields }) => {
|
|
18
31
|
Object.assign(globalThis, { benchmark, setup, teardown, measure, perform });
|
|
19
32
|
|
|
20
33
|
const foundFiles = await glob(patterns);
|
|
@@ -43,7 +56,7 @@ commands
|
|
|
43
56
|
scripts.push(script);
|
|
44
57
|
}
|
|
45
58
|
|
|
46
|
-
await run(scripts, defaultReporter);
|
|
59
|
+
await run(scripts, defaultReporter, fields);
|
|
47
60
|
});
|
|
48
61
|
|
|
49
62
|
commands.on('--help', () => {
|
package/index.js
CHANGED
|
@@ -6,6 +6,32 @@ const suiteContext = createContext();
|
|
|
6
6
|
|
|
7
7
|
export const NOOP = () => {};
|
|
8
8
|
|
|
9
|
+
export const allowedFields = [
|
|
10
|
+
'mode',
|
|
11
|
+
'med',
|
|
12
|
+
'p1',
|
|
13
|
+
'p5',
|
|
14
|
+
'p10',
|
|
15
|
+
'p20',
|
|
16
|
+
'p33',
|
|
17
|
+
'p50',
|
|
18
|
+
'p66',
|
|
19
|
+
'p80',
|
|
20
|
+
'p90',
|
|
21
|
+
'p95',
|
|
22
|
+
'p99',
|
|
23
|
+
'min',
|
|
24
|
+
'max',
|
|
25
|
+
'avg',
|
|
26
|
+
'sum',
|
|
27
|
+
'count',
|
|
28
|
+
'setup',
|
|
29
|
+
'init',
|
|
30
|
+
'cycles',
|
|
31
|
+
'teardown',
|
|
32
|
+
'total',
|
|
33
|
+
];
|
|
34
|
+
|
|
9
35
|
export const setup = (fn) => {
|
|
10
36
|
suiteContext.getContext().setup = fn;
|
|
11
37
|
};
|
|
@@ -57,27 +83,25 @@ const map = {
|
|
|
57
83
|
measure: '✓ Measure',
|
|
58
84
|
};
|
|
59
85
|
|
|
60
|
-
export const defaultReporter = async (type, title, test) => {
|
|
86
|
+
export const defaultReporter = async (type, title, test, fields) => {
|
|
61
87
|
console.group(`${map[type]} ${title}`);
|
|
62
88
|
await test({
|
|
63
|
-
test: defaultReporter,
|
|
89
|
+
test: (...args) => defaultReporter(...args, fields),
|
|
64
90
|
output: (report) =>
|
|
65
91
|
console.table(
|
|
66
92
|
report.success
|
|
67
93
|
? {
|
|
68
|
-
[formatFloat(report.mode)]: {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
count: report.count,
|
|
74
|
-
},
|
|
94
|
+
[formatFloat(report.mode)]: fields.reduce((data, field) => {
|
|
95
|
+
const [key, alias = key] = field.split(':');
|
|
96
|
+
data[alias] = formatFloat(report[key]);
|
|
97
|
+
return data;
|
|
98
|
+
}, {}),
|
|
75
99
|
}
|
|
76
100
|
: {
|
|
77
101
|
error: {
|
|
78
102
|
reason: report.error,
|
|
79
103
|
},
|
|
80
|
-
}
|
|
104
|
+
},
|
|
81
105
|
),
|
|
82
106
|
});
|
|
83
107
|
console.groupEnd();
|
|
@@ -88,31 +112,36 @@ export function formatFloat(value, digits = ACCURACY) {
|
|
|
88
112
|
return parseFloat(value.toFixed(digits));
|
|
89
113
|
}
|
|
90
114
|
|
|
91
|
-
export const run = async (scripts, reporter) => {
|
|
115
|
+
export const run = async (scripts, reporter, fields) => {
|
|
92
116
|
for (const script of scripts) {
|
|
93
|
-
await reporter(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
117
|
+
await reporter(
|
|
118
|
+
'script',
|
|
119
|
+
script.filename,
|
|
120
|
+
async (scriptTest) => {
|
|
121
|
+
for (const suite of script.suites) {
|
|
122
|
+
await scriptTest.test('suite', suite.title, async (suiteTest) => {
|
|
123
|
+
await suiteContext.contextualize(suite, suite.init);
|
|
124
|
+
for (const perform of suite.performs) {
|
|
125
|
+
await suiteTest.test('perform', perform.title, async (performTest) => {
|
|
126
|
+
for (const measure of suite.measures) {
|
|
127
|
+
await performTest.test('measure', perform.count + ' ' + measure.title, async (measureTest) => {
|
|
128
|
+
const result = await runWorker({
|
|
129
|
+
setup: suite.setup,
|
|
130
|
+
teardown: suite.teardown,
|
|
131
|
+
init: measure.init,
|
|
132
|
+
count: perform.count,
|
|
133
|
+
args: perform.args,
|
|
134
|
+
});
|
|
135
|
+
measureTest.output(result);
|
|
107
136
|
});
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
fields,
|
|
144
|
+
);
|
|
116
145
|
}
|
|
117
146
|
};
|
|
118
147
|
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Array copy methods
|
|
2
|
+
|
|
3
|
+
```
|
|
4
|
+
⭐ Script __benchmarks__/array-copy.js
|
|
5
|
+
⇶ Suite Array copy methods
|
|
6
|
+
➤ Perform 10 elements
|
|
7
|
+
✓ Measure 500000 slice
|
|
8
|
+
┌──────────┬──────────┬──────────┬──────────┬───────────┬────────┐
|
|
9
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
10
|
+
├──────────┼──────────┼──────────┼──────────┼───────────┼────────┤
|
|
11
|
+
│ 0.000059 │ 0.000065 │ 0.000105 │ 0.000241 │ 50.160222 │ 500000 │
|
|
12
|
+
└──────────┴──────────┴──────────┴──────────┴───────────┴────────┘
|
|
13
|
+
✓ Measure 500000 spread
|
|
14
|
+
┌──────────┬──────────┬──────────┬──────────┬──────────┬────────┐
|
|
15
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
16
|
+
├──────────┼──────────┼──────────┼──────────┼──────────┼────────┤
|
|
17
|
+
│ 0.000061 │ 0.000067 │ 0.000087 │ 0.000193 │ 44.70032 │ 500000 │
|
|
18
|
+
└──────────┴──────────┴──────────┴──────────┴──────────┴────────┘
|
|
19
|
+
✓ Measure 500000 concat
|
|
20
|
+
┌──────────┬──────────┬──────────┬──────────┬───────────┬────────┐
|
|
21
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
22
|
+
├──────────┼──────────┼──────────┼──────────┼───────────┼────────┤
|
|
23
|
+
│ 0.000061 │ 0.000068 │ 0.000119 │ 0.000234 │ 40.695219 │ 500000 │
|
|
24
|
+
└──────────┴──────────┴──────────┴──────────┴───────────┴────────┘
|
|
25
|
+
✓ Measure 500000 Array.from
|
|
26
|
+
┌──────────┬──────────┬──────────┬──────────┬───────────┬────────┐
|
|
27
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
28
|
+
├──────────┼──────────┼──────────┼──────────┼───────────┼────────┤
|
|
29
|
+
│ 0.000065 │ 0.000072 │ 0.000126 │ 0.000237 │ 50.390629 │ 500000 │
|
|
30
|
+
└──────────┴──────────┴──────────┴──────────┴───────────┴────────┘
|
|
31
|
+
✓ Measure 500000 for loop assign
|
|
32
|
+
┌──────────┬──────────┬──────────┬──────────┬───────────┬────────┐
|
|
33
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
34
|
+
├──────────┼──────────┼──────────┼──────────┼───────────┼────────┤
|
|
35
|
+
│ 0.000066 │ 0.000071 │ 0.000126 │ 0.000287 │ 43.803009 │ 500000 │
|
|
36
|
+
└──────────┴──────────┴──────────┴──────────┴───────────┴────────┘
|
|
37
|
+
✓ Measure 500000 for loop push
|
|
38
|
+
┌──────────┬──────────┬──────────┬──────────┬───────────┬────────┐
|
|
39
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
40
|
+
├──────────┼──────────┼──────────┼──────────┼───────────┼────────┤
|
|
41
|
+
│ 0.000065 │ 0.000072 │ 0.000142 │ 0.000284 │ 43.769935 │ 500000 │
|
|
42
|
+
└──────────┴──────────┴──────────┴──────────┴───────────┴────────┘
|
|
43
|
+
➤ Perform 1000 elements
|
|
44
|
+
✓ Measure 500000 slice
|
|
45
|
+
┌─────────┬──────────┬──────────┬──────────┬────────────┬────────┐
|
|
46
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
47
|
+
├─────────┼──────────┼──────────┼──────────┼────────────┼────────┤
|
|
48
|
+
│ 0.00011 │ 0.000182 │ 0.000371 │ 0.000601 │ 186.871627 │ 500000 │
|
|
49
|
+
└─────────┴──────────┴──────────┴──────────┴────────────┴────────┘
|
|
50
|
+
✓ Measure 500000 spread
|
|
51
|
+
┌──────────┬──────────┬──────────┬──────────┬────────────┬────────┐
|
|
52
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
53
|
+
├──────────┼──────────┼──────────┼──────────┼────────────┼────────┤
|
|
54
|
+
│ 0.000113 │ 0.000186 │ 0.000362 │ 0.000577 │ 186.106348 │ 500000 │
|
|
55
|
+
└──────────┴──────────┴──────────┴──────────┴────────────┴────────┘
|
|
56
|
+
✓ Measure 500000 concat
|
|
57
|
+
┌──────────┬──────────┬──────────┬──────────┬────────────┬────────┐
|
|
58
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
59
|
+
├──────────┼──────────┼──────────┼──────────┼────────────┼────────┤
|
|
60
|
+
│ 0.000116 │ 0.000199 │ 0.000445 │ 0.000772 │ 204.249913 │ 500000 │
|
|
61
|
+
└──────────┴──────────┴──────────┴──────────┴────────────┴────────┘
|
|
62
|
+
✓ Measure 500000 Array.from
|
|
63
|
+
┌──────────┬─────────┬──────────┬──────────┬────────────┬────────┐
|
|
64
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
65
|
+
├──────────┼─────────┼──────────┼──────────┼────────────┼────────┤
|
|
66
|
+
│ 0.000113 │ 0.00019 │ 0.000347 │ 0.000564 │ 190.512575 │ 500000 │
|
|
67
|
+
└──────────┴─────────┴──────────┴──────────┴────────────┴────────┘
|
|
68
|
+
✓ Measure 500000 for loop assign
|
|
69
|
+
┌──────────┬──────────┬──────────┬─────────┬────────────┬────────┐
|
|
70
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
71
|
+
├──────────┼──────────┼──────────┼─────────┼────────────┼────────┤
|
|
72
|
+
│ 0.002016 │ 0.002428 │ 0.003344 │ 0.00437 │ 1477.99805 │ 500000 │
|
|
73
|
+
└──────────┴──────────┴──────────┴─────────┴────────────┴────────┘
|
|
74
|
+
✓ Measure 500000 for loop push
|
|
75
|
+
┌──────────┬──────────┬──────────┬──────────┬─────────────┬────────┐
|
|
76
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
77
|
+
├──────────┼──────────┼──────────┼──────────┼─────────────┼────────┤
|
|
78
|
+
│ 0.002343 │ 0.002756 │ 0.003774 │ 0.006158 │ 1687.568837 │ 500000 │
|
|
79
|
+
└──────────┴──────────┴──────────┴──────────┴─────────────┴────────┘
|
|
80
|
+
```
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Array delete element
|
|
2
|
+
|
|
3
|
+
```
|
|
4
|
+
⭐ Script __benchmarks__/array-delete-element.js
|
|
5
|
+
⇶ Suite Array delete element methods
|
|
6
|
+
➤ Perform 10 elements
|
|
7
|
+
✓ Measure 500000 splice
|
|
8
|
+
┌──────────┬──────────┬──────────┬──────────┬───────────┬────────┐
|
|
9
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
10
|
+
├──────────┼──────────┼──────────┼──────────┼───────────┼────────┤
|
|
11
|
+
│ 0.000072 │ 0.000078 │ 0.000121 │ 0.000248 │ 57.628642 │ 500000 │
|
|
12
|
+
└──────────┴──────────┴──────────┴──────────┴───────────┴────────┘
|
|
13
|
+
✓ Measure 500000 filter
|
|
14
|
+
┌──────────┬──────────┬─────────┬──────────┬───────────┬────────┐
|
|
15
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
16
|
+
├──────────┼──────────┼─────────┼──────────┼───────────┼────────┤
|
|
17
|
+
│ 0.000067 │ 0.000077 │ 0.00018 │ 0.000303 │ 51.695539 │ 500000 │
|
|
18
|
+
└──────────┴──────────┴─────────┴──────────┴───────────┴────────┘
|
|
19
|
+
✓ Measure 500000 for loop
|
|
20
|
+
┌──────────┬──────────┬──────────┬──────────┬───────────┬────────┐
|
|
21
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
22
|
+
├──────────┼──────────┼──────────┼──────────┼───────────┼────────┤
|
|
23
|
+
│ 0.000064 │ 0.000074 │ 0.000119 │ 0.000307 │ 44.446428 │ 500000 │
|
|
24
|
+
└──────────┴──────────┴──────────┴──────────┴───────────┴────────┘
|
|
25
|
+
➤ Perform 1000 elements
|
|
26
|
+
✓ Measure 500000 splice
|
|
27
|
+
┌─────────┬──────────┬──────────┬──────────┬───────────┬────────┐
|
|
28
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
29
|
+
├─────────┼──────────┼──────────┼──────────┼───────────┼────────┤
|
|
30
|
+
│ 0.00007 │ 0.000076 │ 0.000121 │ 0.000268 │ 54.328497 │ 500000 │
|
|
31
|
+
└─────────┴──────────┴──────────┴──────────┴───────────┴────────┘
|
|
32
|
+
✓ Measure 500000 filter
|
|
33
|
+
┌──────────┬──────────┬──────────┬─────────┬────────────┬────────┐
|
|
34
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
35
|
+
├──────────┼──────────┼──────────┼─────────┼────────────┼────────┤
|
|
36
|
+
│ 0.002064 │ 0.002521 │ 0.003448 │ 0.00804 │ 1571.98239 │ 500000 │
|
|
37
|
+
└──────────┴──────────┴──────────┴─────────┴────────────┴────────┘
|
|
38
|
+
✓ Measure 500000 for loop
|
|
39
|
+
┌──────────┬──────────┬──────────┬─────────┬─────────────┬────────┐
|
|
40
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
41
|
+
├──────────┼──────────┼──────────┼─────────┼─────────────┼────────┤
|
|
42
|
+
│ 0.002166 │ 0.002625 │ 0.003383 │ 0.00448 │ 1578.507514 │ 500000 │
|
|
43
|
+
└──────────┴──────────┴──────────┴─────────┴─────────────┴────────┘
|
|
44
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Async functions call performance
|
|
2
|
+
|
|
3
|
+
```
|
|
4
|
+
⭐ Script __benchmarks__/async.js
|
|
5
|
+
⇶ Suite Async functions performance
|
|
6
|
+
➤ Perform 10000000 calls
|
|
7
|
+
✓ Measure 10000000 calls of function that returns Promise.resolve()
|
|
8
|
+
┌─────────┬──────────┬──────────┬─────────┬─────────────┬──────────┐
|
|
9
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
10
|
+
├─────────┼──────────┼──────────┼─────────┼─────────────┼──────────┤
|
|
11
|
+
│ 0.00008 │ 0.000093 │ 0.000138 │ 0.00023 │ 1189.475052 │ 10000000 │
|
|
12
|
+
└─────────┴──────────┴──────────┴─────────┴─────────────┴──────────┘
|
|
13
|
+
✓ Measure 10000000 calls of async function that returns await Promise.resolve()
|
|
14
|
+
┌──────────┬──────────┬──────────┬──────────┬─────────────┬──────────┐
|
|
15
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
16
|
+
├──────────┼──────────┼──────────┼──────────┼─────────────┼──────────┤
|
|
17
|
+
│ 0.000108 │ 0.000122 │ 0.000267 │ 0.000389 │ 1735.581918 │ 10000000 │
|
|
18
|
+
└──────────┴──────────┴──────────┴──────────┴─────────────┴──────────┘
|
|
19
|
+
✓ Measure 10000000 calls of async function that returns Promise.resolve()
|
|
20
|
+
┌──────────┬──────────┬──────────┬──────────┬─────────────┬──────────┐
|
|
21
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
22
|
+
├──────────┼──────────┼──────────┼──────────┼─────────────┼──────────┤
|
|
23
|
+
│ 0.000105 │ 0.000125 │ 0.000203 │ 0.000333 │ 1557.773513 │ 10000000 │
|
|
24
|
+
└──────────┴──────────┴──────────┴──────────┴─────────────┴──────────┘
|
|
25
|
+
```
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Class vs Function
|
|
2
|
+
|
|
3
|
+
```
|
|
4
|
+
⭐ Script __benchmarks__/class-vs-function.js
|
|
5
|
+
⇶ Suite Class vs Function
|
|
6
|
+
➤ Perform Instantiation
|
|
7
|
+
✓ Measure 1000000 class declarations via "class"
|
|
8
|
+
┌──────────┬──────────┬──────────┬──────────┬───────────┬─────────┐
|
|
9
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
10
|
+
├──────────┼──────────┼──────────┼──────────┼───────────┼─────────┤
|
|
11
|
+
│ 0.000438 │ 0.000496 │ 0.001133 │ 0.001602 │ 684.87052 │ 1000000 │
|
|
12
|
+
└──────────┴──────────┴──────────┴──────────┴───────────┴─────────┘
|
|
13
|
+
✓ Measure 1000000 instantiations of the declared class via class and test method call
|
|
14
|
+
┌──────────┬──────────┬──────────┬──────────┬───────────┬─────────┐
|
|
15
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
16
|
+
├──────────┼──────────┼──────────┼──────────┼───────────┼─────────┤
|
|
17
|
+
│ 0.000048 │ 0.000054 │ 0.000059 │ 0.000137 │ 61.055298 │ 1000000 │
|
|
18
|
+
└──────────┴──────────┴──────────┴──────────┴───────────┴─────────┘
|
|
19
|
+
✓ Measure 1000000 class declarations via function
|
|
20
|
+
┌─────────┬──────────┬─────────┬──────────┬──────────┬─────────┐
|
|
21
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
22
|
+
├─────────┼──────────┼─────────┼──────────┼──────────┼─────────┤
|
|
23
|
+
│ 0.00005 │ 0.000056 │ 0.00007 │ 0.000146 │ 63.94922 │ 1000000 │
|
|
24
|
+
└─────────┴──────────┴─────────┴──────────┴──────────┴─────────┘
|
|
25
|
+
✓ Measure 1000000 instantiations of the declared class via function and test method call
|
|
26
|
+
┌──────────┬──────────┬─────────┬──────────┬───────────┬─────────┐
|
|
27
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
28
|
+
├──────────┼──────────┼─────────┼──────────┼───────────┼─────────┤
|
|
29
|
+
│ 0.000049 │ 0.000056 │ 0.00008 │ 0.000189 │ 78.511849 │ 1000000 │
|
|
30
|
+
└──────────┴──────────┴─────────┴──────────┴───────────┴─────────┘
|
|
31
|
+
```
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
### Postgres vs MongoDB
|
|
2
|
+
|
|
3
|
+
```
|
|
4
|
+
⭐ Script __benchmarks__/postgres-vs-mongo.js
|
|
5
|
+
⇶ Suite mongodb vs postgres
|
|
6
|
+
➤ Perform simple test
|
|
7
|
+
✓ Measure 1000 postgres inserts
|
|
8
|
+
┌──────────┬──────────┬──────────┬─────────┬─────────────┬───────┐
|
|
9
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
10
|
+
├──────────┼──────────┼──────────┼─────────┼─────────────┼───────┤
|
|
11
|
+
│ 2.232527 │ 2.256009 │ 2.917856 │ 5.41444 │ 2408.708534 │ 1000 │
|
|
12
|
+
└──────────┴──────────┴──────────┴─────────┴─────────────┴───────┘
|
|
13
|
+
✓ Measure 1000 mongodb inserts
|
|
14
|
+
┌──────────┬──────────┬──────────┬──────────┬─────────────┬───────┐
|
|
15
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
16
|
+
├──────────┼──────────┼──────────┼──────────┼─────────────┼───────┤
|
|
17
|
+
│ 2.955035 │ 2.981828 │ 5.038826 │ 5.467477 │ 3233.680552 │ 1000 │
|
|
18
|
+
└──────────┴──────────┴──────────┴──────────┴─────────────┴───────┘
|
|
19
|
+
✓ Measure 1000 postgres query data
|
|
20
|
+
┌─────────┬──────────┬──────────┬──────────┬────────────┬───────┐
|
|
21
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
22
|
+
├─────────┼──────────┼──────────┼──────────┼────────────┼───────┤
|
|
23
|
+
│ 0.28218 │ 0.297544 │ 0.393615 │ 0.561729 │ 308.713494 │ 1000 │
|
|
24
|
+
└─────────┴──────────┴──────────┴──────────┴────────────┴───────┘
|
|
25
|
+
✓ Measure 1000 mongodb query data
|
|
26
|
+
┌──────────┬──────────┬──────────┬──────────┬───────────┬───────┐
|
|
27
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
28
|
+
├──────────┼──────────┼──────────┼──────────┼───────────┼───────┤
|
|
29
|
+
│ 0.457289 │ 0.461665 │ 0.693627 │ 0.919116 │ 495.27099 │ 1000 │
|
|
30
|
+
└──────────┴──────────┴──────────┴──────────┴───────────┴───────┘
|
|
31
|
+
✓ Measure 1000 postgres query inserts
|
|
32
|
+
┌──────────┬──────────┬──────────┬──────────┬─────────────┬───────┐
|
|
33
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
34
|
+
├──────────┼──────────┼──────────┼──────────┼─────────────┼───────┤
|
|
35
|
+
│ 2.491574 │ 2.500577 │ 3.524734 │ 6.177946 │ 2681.101875 │ 1000 │
|
|
36
|
+
└──────────┴──────────┴──────────┴──────────┴─────────────┴───────┘
|
|
37
|
+
✓ Measure 1000 mongodb query inserts
|
|
38
|
+
┌──────────┬──────────┬──────────┬─────────┬─────────────┬───────┐
|
|
39
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
40
|
+
├──────────┼──────────┼──────────┼─────────┼─────────────┼───────┤
|
|
41
|
+
│ 3.946823 │ 3.921073 │ 5.969672 │ 6.26903 │ 3954.008642 │ 1000 │
|
|
42
|
+
└──────────┴──────────┴──────────┴─────────┴─────────────┴───────┘
|
|
43
|
+
✓ Measure 1000 postgres group data
|
|
44
|
+
┌──────────┬──────────┬──────────┬──────────┬────────────┬───────┐
|
|
45
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
46
|
+
├──────────┼──────────┼──────────┼──────────┼────────────┼───────┤
|
|
47
|
+
│ 0.287954 │ 0.272375 │ 0.347489 │ 0.494122 │ 279.076014 │ 1000 │
|
|
48
|
+
└──────────┴──────────┴──────────┴──────────┴────────────┴───────┘
|
|
49
|
+
✓ Measure 1000 mongodb group data
|
|
50
|
+
┌──────────┬──────────┬──────────┬──────────┬────────────┬───────┐
|
|
51
|
+
│ (index) │ med │ p95 │ p99 │ total │ count │
|
|
52
|
+
├──────────┼──────────┼──────────┼──────────┼────────────┼───────┤
|
|
53
|
+
│ 0.564809 │ 0.556707 │ 0.666702 │ 0.851308 │ 569.134585 │ 1000 │
|
|
54
|
+
└──────────┴──────────┴──────────┴──────────┴────────────┴───────┘
|
|
55
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "overtake",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "NodeJS performance benchmark",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -30,16 +30,18 @@
|
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://github.com/3axap4eHko/overtake#readme",
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@jest/globals": "^29.
|
|
34
|
-
"@types/jest": "^29.5.
|
|
35
|
-
"husky": "^
|
|
36
|
-
"jest": "^29.
|
|
37
|
-
"
|
|
38
|
-
"
|
|
33
|
+
"@jest/globals": "^29.7.0",
|
|
34
|
+
"@types/jest": "^29.5.12",
|
|
35
|
+
"husky": "^9.0.11",
|
|
36
|
+
"jest": "^29.7.0",
|
|
37
|
+
"mongodb": "^6.4.0",
|
|
38
|
+
"pg": "^8.11.3",
|
|
39
|
+
"prettier": "^3.2.5",
|
|
40
|
+
"pretty-quick": "^4.0.0"
|
|
39
41
|
},
|
|
40
42
|
"dependencies": {
|
|
41
|
-
"commander": "^
|
|
43
|
+
"commander": "^12.0.0",
|
|
42
44
|
"conode": "^0.1.23",
|
|
43
|
-
"glob": "^
|
|
45
|
+
"glob": "^10.3.10"
|
|
44
46
|
}
|
|
45
47
|
}
|