Skip to content

Commit 6e8f4fe

Browse files
committed
feat: add three libraries to benchmark
Add the following libraries to the benchmark: - `json-p3`: https://github.com/JG-1202/Js-JSON-GO - `js-json-go`: https://github.com/JG-1202/Js-JSON-GO - `json-power-query`: https://github.com/TotalTechGeek/json-power-query Also: - update all packages - use biome to format/lint the code - switch to pnpm
1 parent ef89f9c commit 6e8f4fe

18 files changed

+1354
-829
lines changed

README.md

Lines changed: 110 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,21 @@ The libraries tested are:
88
| [json-query](https://www.npmjs.com/package/json-query) | [![npm](https://img.shields.io/npm/dw/json-query.svg)](https://www.npmjs.com/package/json-query) | ![GitHub last commit](https://img.shields.io/github/last-commit/mmckegg/json-query.svg) |
99
| [jsonpath-plus](https://www.npmjs.com/package/jsonpath-plus) | [![npm](https://img.shields.io/npm/dw/jsonpath-plus.svg)](https://www.npmjs.com/package/jsonpath-plus) | ![GitHub last commit](https://img.shields.io/github/last-commit/s3u/JSONPath.svg) |
1010
| [jsonpath](https://www.npmjs.com/package/jsonpath) | [![npm](https://img.shields.io/npm/dw/jsonpath.svg)](https://www.npmjs.com/package/jsonpath) | ![GitHub last commit](https://img.shields.io/github/last-commit/dchester/jsonpath.svg) |
11+
| [json-p3](https://www.npmjs.com/package/json-p3) | [![npm](https://img.shields.io/npm/dw/json-p3.svg)](https://www.npmjs.com/package/json-p3) | ![GitHub last commit](https://img.shields.io/github/last-commit/jg-rp/json-p3.svg) |
12+
| [js-json-go](https://www.npmjs.com/package/js-json-go) | [![npm](https://img.shields.io/npm/dw/js-json-go.svg)](https://www.npmjs.com/package/jg-json-go) | ![GitHub last commit](https://img.shields.io/github/last-commit/JG-1202/js-json-go.svg) |
13+
| [json-power-query](https://www.npmjs.com/package/json-power-query) | [![npm](https://img.shields.io/npm/dw/json-power-query.svg)](https://www.npmjs.com/package/json-power-query) | ![GitHub last commit](https://img.shields.io/github/last-commit/TotalTechGeek/json-power-query.svg) |
1114
| [JSONStream](https://www.npmjs.com/package/JSONStream) | [![npm](https://img.shields.io/npm/dw/JSONStream.svg)](https://www.npmjs.com/package/JSONStream) | ![GitHub last commit](https://img.shields.io/github/last-commit/dominictarr/JSONStream.svg) |
1215
| [oboe](https://www.npmjs.com/package/oboe) | [![npm](https://img.shields.io/npm/dw/oboe.svg)](https://www.npmjs.com/package/oboe) | ![GitHub last commit](https://img.shields.io/github/last-commit/jimhigson/oboe.js.svg) |
13-
| [map-filter-reduce](https://www.npmjs.com/package/map-filter-reduce) | [![npm](https://img.shields.io/npm/dw/map-filter-reduce.svg)](https://www.npmjs.com/package/map-filter-reduce) | ![GitHub last commit](https://img.shields.io/github/last-commit/dominictarr/map-filter-reduce.svg) |
16+
| [map-filter-reduce](https://www.npmjs.com/package/map-filter-reduce) | [![npm](https://img.shields.io/npm/dw/map-filter-reduce.svg)](https://www.npmjs.com/package/map-filter-reduce) | ![GitHub last commit](https://img.shields.io/github/last-commit/jg-rp/json-p3.svg) |
1417

1518
`jsonpath-plus` and `jsonpath` use the [XPath for Json Specification](https://goessner.net/articles/JsonPath).
16-
`json-query` has its own custom DSL. `JSONStream`, `oboe`, and `map-filter-reduce` are streaming libraries, though I've had varying success in making them anywhere near as performant.
19+
`json-query`, `json-p3` and `json-js-go` has its own custom DSL. `JSONStream`, `oboe`, and `map-filter-reduce` are streaming libraries, though I've had varying success in making them anywhere near as performant.
1720

1821
## How to run
1922

2023
```
21-
npm install
22-
npm run perf
24+
pnpm install
25+
pnpm run perf
2326
```
2427

2528
### Method Explaination
@@ -34,58 +37,82 @@ The performance test runs three queries on each of the libraries. All three quer
3437

3538
### Results
3639

37-
Ran using Macbook Pro, 2.2 GHz Intel Core i7, 16 GB 2400 MHz DDR4
40+
Ran using Macbook Pro, Apple M2 Max 12c, 32GB RAM, Node v21.4.0
3841

3942
```
40-
$ npm run perf
43+
$ pnpm run perf
4144
42-
> [email protected] perf /Users/andrew/Code/scratchwork/perf-json-querying
43-
> node --max-old-space-size=4096 src
45+
> [email protected] perf /Users/jbergstroem/wrk/oss/json-querying-performance-testing
46+
> node --max-old-space-size=4096 --expose-gc src
4447
4548
smallCityLots 49998 items.
4649
mediumCityLots 99998 items.
4750
largeCityLots 206560 items.
4851
4952
smallCityLots:
5053
- json-query:
51-
- shallow took 0.0176 seconds.
52-
- deep took 0.0502 seconds.
53-
- conditional took 0.0408 seconds.
54+
- shallow took 0.0047 seconds.
55+
- deep took 0.0048 seconds.
56+
- conditional took 0.0062 seconds.
5457
- jsonpath-plus:
55-
- shallow took 0.4146 seconds.
56-
- deep took 0.4239 seconds.
57-
- conditional took 0.326 seconds.
58+
- shallow took 0.1355 seconds.
59+
- deep took 0.1339 seconds.
60+
- conditional took 0.0342 seconds.
5861
- jsonpath:
59-
- shallow took 1.1165 seconds.
60-
- deep took 4.4373 seconds.
61-
- conditional took 0.1387 seconds.
62+
- shallow took 0.3711 seconds.
63+
- deep took 2.3432 seconds.
64+
- conditional took 0.0116 seconds.
65+
- json-p3:
66+
- shallow took 0.6913 seconds.
67+
- deep took 0.5962 seconds.
68+
- conditional took 0.029 seconds.
69+
- js-json-go:
70+
- shallow took 0.0434 seconds.
71+
- deep took 0.0399 seconds.
72+
- conditional took 0.0616 seconds.
73+
- json-power-query:
74+
- shallow took 0.0029 seconds.
75+
- deep took 0.0028 seconds.
76+
- conditional took 0.0037 seconds.
6277
- JSONStream:
63-
- shallow took 20.5 seconds.
64-
- deep took 23.5372 seconds.
78+
- shallow took 0.9522 seconds.
79+
- deep took 0.9774 seconds.
6580
- oboe:
66-
- shallow took 25.0891 seconds.
67-
- deep took 32.5883 seconds.
81+
- shallow took 1.1483 seconds.
82+
- deep took 1.1847 seconds.
6883
- map-filter-reduce:
6984
7085
mediumCityLots:
7186
- json-query:
72-
- shallow took 0.0489 seconds.
73-
- deep took 0.0732 seconds.
74-
- conditional took 0.0488 seconds.
87+
- shallow took 0.0055 seconds.
88+
- deep took 0.0091 seconds.
89+
- conditional took 0.0083 seconds.
7590
- jsonpath-plus:
76-
- shallow took 0.8285 seconds.
77-
- deep took 0.8567 seconds.
78-
- conditional took 0.6074 seconds.
91+
- shallow took 0.2546 seconds.
92+
- deep took 0.272 seconds.
93+
- conditional took 0.0593 seconds.
7994
- jsonpath:
80-
- shallow took 2.2047 seconds.
81-
- deep took 37.187 seconds.
82-
- conditional took 0.2852 seconds.
95+
- shallow took 0.7684 seconds.
96+
- deep took 8.2911 seconds.
97+
- conditional took 0.0192 seconds.
98+
- json-p3:
99+
- shallow took 1.4808 seconds.
100+
- deep took 1.2317 seconds.
101+
- conditional took 0.0475 seconds.
102+
- js-json-go:
103+
- shallow took 0.0712 seconds.
104+
- deep took 0.0634 seconds.
105+
- conditional took 0.1034 seconds.
106+
- json-power-query:
107+
- shallow took 0.0051 seconds.
108+
- deep took 0.0044 seconds.
109+
- conditional took 0.0038 seconds.
83110
- JSONStream:
84-
- shallow took 199.4793 seconds.
85-
- deep took 5.0332 seconds.
111+
- shallow took 2.0166 seconds.
112+
- deep took 2.048 seconds.
86113
- oboe:
87-
- shallow took 27.819 seconds.
88-
- deep took 77.9259 seconds.
114+
- shallow took 2.4415 seconds.
115+
- deep took 2.4524 seconds.
89116
- map-filter-reduce:
90117
91118
largeCityLots:
@@ -94,19 +121,31 @@ json-query shallow failed, RangeError: Maximum call stack size exceeded.
94121
json-query deep failed, RangeError: Maximum call stack size exceeded.
95122
json-query conditional failed, RangeError: Maximum call stack size exceeded.
96123
- jsonpath-plus:
97-
- shallow took 2.3345 seconds.
98-
- deep took 2.472 seconds.
99-
- conditional took 3.1351 seconds.
124+
- shallow took 0.7001 seconds.
125+
- deep took 0.7331 seconds.
126+
- conditional took 0.1226 seconds.
100127
- jsonpath:
101-
- shallow took 8.509 seconds.
102-
- deep took 252.9623 seconds.
103-
- conditional took 0.7586 seconds.
128+
- shallow took 2.1981 seconds.
129+
- deep took 33.633 seconds.
130+
- conditional took 0.0452 seconds.
131+
- json-p3:
132+
- shallow took 5.3844 seconds.
133+
- deep took 5.3054 seconds.
134+
- conditional took 0.1007 seconds.
135+
- js-json-go:
136+
- shallow took 0.1173 seconds.
137+
- deep took 0.12 seconds.
138+
- conditional took 0.2242 seconds.
139+
- json-power-query:
140+
- shallow took 0.0117 seconds.
141+
- deep took 0.0113 seconds.
142+
- conditional took 0.0093 seconds.
104143
- JSONStream:
105-
- shallow took 54.8295 seconds.
106-
- deep took 146.2962 seconds.
144+
- shallow took 6.0252 seconds.
145+
- deep took 6.0345 seconds.
107146
- oboe:
108-
- shallow took 148.8824 seconds.
109-
- deep took 216.7555 seconds.
147+
- shallow took 7.341 seconds.
148+
- deep took 7.2204 seconds.
110149
- map-filter-reduce:
111150
112151
@@ -115,35 +154,44 @@ summary:
115154
116155
smallCityLots
117156
┌───────────────────┬───────────────────┬───────────────────┬───────────────────┐
118-
(index)shallowdeepconditional
157+
(index)shallowdeepconditional
119158
├───────────────────┼───────────────────┼───────────────────┼───────────────────┤
120-
│ json-query │ 0.0176 │ 0.0502 │ 0.0408 │
121-
│ jsonpath-plus │ 0.4146 │ 0.4239 │ 0.326 │
122-
│ jsonpath │ 1.1165 │ 4.4373 │ 0.1387 │
123-
│ JSONStream │ 20.5 │ 23.5372 │ 'not possible' │
124-
│ oboe │ 25.0891 │ 32.5883 │ 'not possible' │
159+
│ json-query │ 0.0047 │ 0.0048 │ 0.0062 │
160+
│ jsonpath-plus │ 0.1355 │ 0.1339 │ 0.0342 │
161+
│ jsonpath │ 0.3711 │ 2.3432 │ 0.0116 │
162+
│ json-p3 │ 0.6913 │ 0.5962 │ 0.029 │
163+
│ js-json-go │ 0.0434 │ 0.0399 │ 0.0616 │
164+
│ json-power-query │ 0.0029 │ 0.0028 │ 0.0037 │
165+
│ JSONStream │ 0.9522 │ 0.9774 │ 'not possible' │
166+
│ oboe │ 1.1483 │ 1.1847 │ 'not possible' │
125167
│ map-filter-reduce │ 'not implemented' │ 'not implemented' │ 'not implemented' │
126168
└───────────────────┴───────────────────┴───────────────────┴───────────────────┘
127169
mediumCityLots
128170
┌───────────────────┬───────────────────┬───────────────────┬───────────────────┐
129-
(index)shallowdeepconditional
171+
(index)shallowdeepconditional
130172
├───────────────────┼───────────────────┼───────────────────┼───────────────────┤
131-
│ json-query │ 0.0489 │ 0.0732 │ 0.0488 │
132-
│ jsonpath-plus │ 0.8285 │ 0.8567 │ 0.6074 │
133-
│ jsonpath │ 2.2047 │ 37.187 │ 0.2852 │
134-
│ JSONStream │ 199.4793 │ 5.0332 │ 'not possible' │
135-
│ oboe │ 27.819 │ 77.9259 │ 'not possible' │
173+
│ json-query │ 0.0055 │ 0.0091 │ 0.0083 │
174+
│ jsonpath-plus │ 0.2546 │ 0.272 │ 0.0593 │
175+
│ jsonpath │ 0.7684 │ 8.2911 │ 0.0192 │
176+
│ json-p3 │ 1.4808 │ 1.2317 │ 0.0475 │
177+
│ js-json-go │ 0.0712 │ 0.0634 │ 0.1034 │
178+
│ json-power-query │ 0.0051 │ 0.0044 │ 0.0038 │
179+
│ JSONStream │ 2.0166 │ 2.048 │ 'not possible' │
180+
│ oboe │ 2.4415 │ 2.4524 │ 'not possible' │
136181
│ map-filter-reduce │ 'not implemented' │ 'not implemented' │ 'not implemented' │
137182
└───────────────────┴───────────────────┴───────────────────┴───────────────────┘
138183
largeCityLots
139184
┌───────────────────┬───────────────────┬───────────────────┬───────────────────┐
140-
(index)shallowdeepconditional
185+
(index)shallowdeepconditional
141186
├───────────────────┼───────────────────┼───────────────────┼───────────────────┤
142-
│ json-query │ 'failed' │ 'failed' │ 'failed' │
143-
│ jsonpath-plus │ 2.3345 │ 2.472 │ 3.1351 │
144-
│ jsonpath │ 8.509 │ 252.9623 │ 0.7586 │
145-
│ JSONStream │ 54.8295 │ 146.2962 │ 'not possible' │
146-
│ oboe │ 148.8824 │ 216.7555 │ 'not possible' │
187+
│ json-query │ 'failed' │ 'failed' │ 'failed' │
188+
│ jsonpath-plus │ 0.7001 │ 0.7331 │ 0.1226 │
189+
│ jsonpath │ 2.1981 │ 33.633 │ 0.0452 │
190+
│ json-p3 │ 5.3844 │ 5.3054 │ 0.1007 │
191+
│ js-json-go │ 0.1173 │ 0.12 │ 0.2242 │
192+
│ json-power-query │ 0.0117 │ 0.0113 │ 0.0093 │
193+
│ JSONStream │ 6.0252 │ 6.0345 │ 'not possible' │
194+
│ oboe │ 7.341 │ 7.2204 │ 'not possible' │
147195
│ map-filter-reduce │ 'not implemented' │ 'not implemented' │ 'not implemented' │
148196
└───────────────────┴───────────────────┴───────────────────┴───────────────────┘
149197
```

biome.json

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3+
"vcs": {
4+
"enabled": true,
5+
"clientKind": "git",
6+
"useIgnoreFile": true
7+
},
8+
"organizeImports": {
9+
"enabled": true
10+
},
11+
"linter": {
12+
"enabled": true,
13+
"rules": {
14+
"recommended": false,
15+
"correctness": {
16+
"all": false,
17+
"noUnusedVariables": "error",
18+
"noPrecisionLoss": "error"
19+
},
20+
"suspicious": {
21+
"all": false,
22+
"noControlCharactersInRegex": "error"
23+
}
24+
},
25+
"ignore": ["datasets"]
26+
},
27+
"files": {
28+
"ignoreUnknown": true
29+
},
30+
"formatter": {
31+
"enabled": true,
32+
"formatWithErrors": true,
33+
"indentStyle": "space",
34+
"indentWidth": 2,
35+
"lineWidth": 120,
36+
"ignore": ["datasets"]
37+
},
38+
"javascript": {
39+
"formatter": {
40+
"enabled": true,
41+
"quoteStyle": "single",
42+
"arrowParentheses": "asNeeded",
43+
"trailingComma": "all",
44+
"lineEnding": "lf"
45+
},
46+
"parser": {
47+
"unsafeParameterDecoratorsEnabled": true
48+
}
49+
},
50+
"json": {
51+
"formatter": {
52+
"enabled": true
53+
}
54+
}
55+
}

0 commit comments

Comments
 (0)