Skip to content

Commit 0b040b0

Browse files
committed
feat: add json-p3 to the benchmark
Also: - update all packages - switch to pnpm
1 parent ef89f9c commit 0b040b0

File tree

6 files changed

+984
-663
lines changed

6 files changed

+984
-663
lines changed

README.md

Lines changed: 76 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@ The libraries tested are:
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) |
1111
| [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) |
1212
| [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) |
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/jg-rp/json-p3.svg) |
14+
| [map-filter-reduce](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) |
1415

1516
`jsonpath-plus` and `jsonpath` use the [XPath for Json Specification](https://goessner.net/articles/JsonPath).
1617
`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.
1718

1819
## How to run
1920

2021
```
21-
npm install
22-
npm run perf
22+
pnpm install
23+
pnpm run perf
2324
```
2425

2526
### Method Explaination
@@ -34,12 +35,12 @@ The performance test runs three queries on each of the libraries. All three quer
3435

3536
### Results
3637

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

3940
```
40-
$ npm run perf
41+
$ pnpm run perf
4142
42-
> [email protected] perf /Users/andrew/Code/scratchwork/perf-json-querying
43+
4344
> node --max-old-space-size=4096 src
4445
4546
smallCityLots 49998 items.
@@ -48,44 +49,52 @@ largeCityLots 206560 items.
4849
4950
smallCityLots:
5051
- json-query:
51-
- shallow took 0.0176 seconds.
52-
- deep took 0.0502 seconds.
53-
- conditional took 0.0408 seconds.
52+
- shallow took 0.0029 seconds.
53+
- deep took 0.0039 seconds.
54+
- conditional took 0.0042 seconds.
5455
- jsonpath-plus:
55-
- shallow took 0.4146 seconds.
56-
- deep took 0.4239 seconds.
57-
- conditional took 0.326 seconds.
56+
- shallow took 0.1293 seconds.
57+
- deep took 0.1245 seconds.
58+
- conditional took 0.0307 seconds.
5859
- jsonpath:
59-
- shallow took 1.1165 seconds.
60-
- deep took 4.4373 seconds.
61-
- conditional took 0.1387 seconds.
60+
- shallow took 0.3659 seconds.
61+
- deep took 2.4884 seconds.
62+
- conditional took 0.0104 seconds.
6263
- JSONStream:
63-
- shallow took 20.5 seconds.
64-
- deep took 23.5372 seconds.
64+
- shallow took 0.9352 seconds.
65+
- deep took 0.9764 seconds.
6566
- oboe:
66-
- shallow took 25.0891 seconds.
67-
- deep took 32.5883 seconds.
67+
- shallow took 1.1457 seconds.
68+
- deep took 1.1622 seconds.
69+
- jsonp3:
70+
- shallow took 0.6297 seconds.
71+
- deep took 0.6377 seconds.
72+
- conditional took 0.0283 seconds.
6873
- map-filter-reduce:
6974
7075
mediumCityLots:
7176
- json-query:
72-
- shallow took 0.0489 seconds.
73-
- deep took 0.0732 seconds.
74-
- conditional took 0.0488 seconds.
77+
- shallow took 0.0051 seconds.
78+
- deep took 0.0076 seconds.
79+
- conditional took 0.0063 seconds.
7580
- jsonpath-plus:
76-
- shallow took 0.8285 seconds.
77-
- deep took 0.8567 seconds.
78-
- conditional took 0.6074 seconds.
81+
- shallow took 0.2652 seconds.
82+
- deep took 0.271 seconds.
83+
- conditional took 0.0541 seconds.
7984
- jsonpath:
80-
- shallow took 2.2047 seconds.
81-
- deep took 37.187 seconds.
82-
- conditional took 0.2852 seconds.
85+
- shallow took 0.7908 seconds.
86+
- deep took 9.5185 seconds.
87+
- conditional took 0.0177 seconds.
8388
- JSONStream:
84-
- shallow took 199.4793 seconds.
85-
- deep took 5.0332 seconds.
89+
- shallow took 2.1011 seconds.
90+
- deep took 2.0387 seconds.
8691
- oboe:
87-
- shallow took 27.819 seconds.
88-
- deep took 77.9259 seconds.
92+
- shallow took 2.3883 seconds.
93+
- deep took 2.4104 seconds.
94+
- jsonp3:
95+
- shallow took 1.392 seconds.
96+
- deep took 1.6872 seconds.
97+
- conditional took 0.036 seconds.
8998
- map-filter-reduce:
9099
91100
largeCityLots:
@@ -94,19 +103,23 @@ json-query shallow failed, RangeError: Maximum call stack size exceeded.
94103
json-query deep failed, RangeError: Maximum call stack size exceeded.
95104
json-query conditional failed, RangeError: Maximum call stack size exceeded.
96105
- jsonpath-plus:
97-
- shallow took 2.3345 seconds.
98-
- deep took 2.472 seconds.
99-
- conditional took 3.1351 seconds.
106+
- shallow took 0.7212 seconds.
107+
- deep took 0.7555 seconds.
108+
- conditional took 0.1134 seconds.
100109
- jsonpath:
101-
- shallow took 8.509 seconds.
102-
- deep took 252.9623 seconds.
103-
- conditional took 0.7586 seconds.
110+
- shallow took 2.2774 seconds.
111+
- deep took 35.221 seconds.
112+
- conditional took 0.0405 seconds.
104113
- JSONStream:
105-
- shallow took 54.8295 seconds.
106-
- deep took 146.2962 seconds.
114+
- shallow took 6.0883 seconds.
115+
- deep took 6.1142 seconds.
107116
- oboe:
108-
- shallow took 148.8824 seconds.
109-
- deep took 216.7555 seconds.
117+
- shallow took 7.0838 seconds.
118+
- deep took 7.1547 seconds.
119+
- jsonp3:
120+
- shallow took 6.8737 seconds.
121+
- deep took 7.4648 seconds.
122+
- conditional took 0.0897 seconds.
110123
- map-filter-reduce:
111124
112125
@@ -115,35 +128,38 @@ summary:
115128
116129
smallCityLots
117130
┌───────────────────┬───────────────────┬───────────────────┬───────────────────┐
118-
(index)shallowdeepconditional
131+
(index)shallowdeepconditional
119132
├───────────────────┼───────────────────┼───────────────────┼───────────────────┤
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' │
133+
│ json-query │ 0.0029 │ 0.0039 │ 0.0042 │
134+
│ jsonpath-plus │ 0.1293 │ 0.1245 │ 0.0307 │
135+
│ jsonpath │ 0.3659 │ 2.4884 │ 0.0104 │
136+
│ JSONStream │ 0.9352 │ 0.9764 │ 'not possible' │
137+
│ oboe │ 1.1457 │ 1.1622 │ 'not possible' │
138+
│ jsonp3 │ 0.6297 │ 0.6377 │ 0.0283 │
125139
│ map-filter-reduce │ 'not implemented' │ 'not implemented' │ 'not implemented' │
126140
└───────────────────┴───────────────────┴───────────────────┴───────────────────┘
127141
mediumCityLots
128142
┌───────────────────┬───────────────────┬───────────────────┬───────────────────┐
129-
(index)shallowdeepconditional
143+
(index)shallowdeepconditional
130144
├───────────────────┼───────────────────┼───────────────────┼───────────────────┤
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' │
145+
│ json-query │ 0.0051 │ 0.0076 │ 0.0063 │
146+
│ jsonpath-plus │ 0.2652 │ 0.271 │ 0.0541 │
147+
│ jsonpath │ 0.7908 │ 9.5185 │ 0.0177 │
148+
│ JSONStream │ 2.1011 │ 2.0387 │ 'not possible' │
149+
│ oboe │ 2.3883 │ 2.4104 │ 'not possible' │
150+
│ jsonp3 │ 1.392 │ 1.6872 │ 0.036 │
136151
│ map-filter-reduce │ 'not implemented' │ 'not implemented' │ 'not implemented' │
137152
└───────────────────┴───────────────────┴───────────────────┴───────────────────┘
138153
largeCityLots
139154
┌───────────────────┬───────────────────┬───────────────────┬───────────────────┐
140-
(index)shallowdeepconditional
155+
(index)shallowdeepconditional
141156
├───────────────────┼───────────────────┼───────────────────┼───────────────────┤
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' │
157+
│ json-query │ 'failed' │ 'failed' │ 'failed' │
158+
│ jsonpath-plus │ 0.7212 │ 0.7555 │ 0.1134 │
159+
│ jsonpath │ 2.2774 │ 35.221 │ 0.0405 │
160+
│ JSONStream │ 6.0883 │ 6.1142 │ 'not possible' │
161+
│ oboe │ 7.0838 │ 7.1547 │ 'not possible' │
162+
│ jsonp3 │ 6.8737 │ 7.4648 │ 0.0897 │
147163
│ map-filter-reduce │ 'not implemented' │ 'not implemented' │ 'not implemented' │
148164
└───────────────────┴───────────────────┴───────────────────┴───────────────────┘
149165
```

0 commit comments

Comments
 (0)