|
1 | 1 | # Json Querying Performance Testing
|
2 | 2 |
|
3 |
| -This repo is used to test the performance of json querying npm packages. The dataset used is [City Lots San |
4 |
| -Francisco in .json](https://github.com/zemirco/sf-city-lots-json). The three libraries tested are: |
| 3 | +This repo is used to test the performance of json querying npm packages. The dataset used is [City Lots San Francisco in .json](https://github.com/zemirco/sf-city-lots-json). |
| 4 | +The libraries tested are: |
5 | 5 |
|
6 |
| -- [json-query](https://www.npmjs.com/package/json-query) [](https://www.npmjs.com/package/json-query) |
7 |
| -- [jsonpath-plus](https://www.npmjs.com/package/jsonpath-plus) [](https://www.npmjs.com/package/jsonpath-plus) |
8 |
| -- [jsonpath](https://www.npmjs.com/package/jsonpath) [](https://www.npmjs.com/package/jsonpath) |
9 |
| -- [JSONStream](https://www.npmjs.com/package/JSONStream) [](https://www.npmjs.com/package/JSONStream) |
| 6 | +| Package | NPM Downloads | Last commit | |
| 7 | +| :-- | :-- | :-- | |
| 8 | +| [json-query](https://www.npmjs.com/package/json-query) | [](https://www.npmjs.com/package/json-query) |  | |
| 9 | +| [jsonpath-plus](https://www.npmjs.com/package/jsonpath-plus) | [](https://www.npmjs.com/package/jsonpath-plus) |  | |
| 10 | +| [jsonpath](https://www.npmjs.com/package/jsonpath) | [](https://www.npmjs.com/package/jsonpath) |  | |
| 11 | +| [JSONStream](https://www.npmjs.com/package/JSONStream) | [](https://www.npmjs.com/package/JSONStream) |  | |
| 12 | +| [oboe](https://www.npmjs.com/package/oboe) | [](https://www.npmjs.com/package/oboe) |  | |
| 13 | +| [map-filter-reduce](https://www.npmjs.com/package/map-filter-reduce) | [](https://www.npmjs.com/package/map-filter-reduce) |  | |
10 | 14 |
|
11 |
| -`jsonpath-plus` and `jsonpath` use the [XPath for Json Specification](https://goessner.net/articles/JsonPath), |
12 |
| -while `json-query` has its own custom DSL. |
| 15 | +`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. |
13 | 17 |
|
14 | 18 | ## How to run
|
15 | 19 |
|
@@ -44,89 +48,102 @@ largeCityLots 206560 items.
|
44 | 48 |
|
45 | 49 | smallCityLots:
|
46 | 50 | - json-query:
|
47 |
| - - shallow took 0.0329 seconds. |
48 |
| - - deep took 0.0495 seconds. |
49 |
| - - conditional took 0.0455 seconds. |
| 51 | + - shallow took 0.0176 seconds. |
| 52 | + - deep took 0.0502 seconds. |
| 53 | + - conditional took 0.0408 seconds. |
50 | 54 | - jsonpath-plus:
|
51 |
| - - shallow took 0.3907 seconds. |
52 |
| - - deep took 0.3808 seconds. |
53 |
| - - conditional took 0.3051 seconds. |
| 55 | + - shallow took 0.4146 seconds. |
| 56 | + - deep took 0.4239 seconds. |
| 57 | + - conditional took 0.326 seconds. |
54 | 58 | - jsonpath:
|
55 |
| - - shallow took 1.0639 seconds. |
56 |
| - - deep took 6.0417 seconds. |
57 |
| - - conditional took 0.0285 seconds. |
| 59 | + - shallow took 1.1165 seconds. |
| 60 | + - deep took 4.4373 seconds. |
| 61 | + - conditional took 0.1387 seconds. |
58 | 62 | - JSONStream:
|
59 |
| - - shallow took 2.4209 seconds. |
60 |
| - - deep took 2.4758 seconds. |
61 |
| - - conditional took 2.0678 seconds. |
62 |
| -JSONStream conditional AssertError: result should have length 643 but instead is 0 |
| 63 | + - shallow took 20.5 seconds. |
| 64 | + - deep took 23.5372 seconds. |
| 65 | +- oboe: |
| 66 | + - shallow took 25.0891 seconds. |
| 67 | + - deep took 32.5883 seconds. |
| 68 | +- map-filter-reduce: |
63 | 69 |
|
64 | 70 | mediumCityLots:
|
65 | 71 | - json-query:
|
66 |
| - - shallow took 0.0416 seconds. |
67 |
| - - deep took 0.0743 seconds. |
68 |
| - - conditional took 0.0491 seconds. |
| 72 | + - shallow took 0.0489 seconds. |
| 73 | + - deep took 0.0732 seconds. |
| 74 | + - conditional took 0.0488 seconds. |
69 | 75 | - jsonpath-plus:
|
70 |
| - - shallow took 0.7514 seconds. |
71 |
| - - deep took 0.8055 seconds. |
72 |
| - - conditional took 0.6247 seconds. |
| 76 | + - shallow took 0.8285 seconds. |
| 77 | + - deep took 0.8567 seconds. |
| 78 | + - conditional took 0.6074 seconds. |
73 | 79 | - jsonpath:
|
74 |
| - - shallow took 2.231 seconds. |
75 |
| - - deep took 36.6839 seconds. |
76 |
| - - conditional took 0.0478 seconds. |
| 80 | + - shallow took 2.2047 seconds. |
| 81 | + - deep took 37.187 seconds. |
| 82 | + - conditional took 0.2852 seconds. |
77 | 83 | - JSONStream:
|
78 |
| - - shallow took 4.8281 seconds. |
79 |
| - - deep took 5.4624 seconds. |
80 |
| - - conditional took 4.0842 seconds. |
81 |
| -JSONStream conditional AssertError: result should have length 824 but instead is 0 |
| 84 | + - shallow took 199.4793 seconds. |
| 85 | + - deep took 5.0332 seconds. |
| 86 | +- oboe: |
| 87 | + - shallow took 27.819 seconds. |
| 88 | + - deep took 77.9259 seconds. |
| 89 | +- map-filter-reduce: |
82 | 90 |
|
83 | 91 | largeCityLots:
|
84 | 92 | - json-query:
|
85 | 93 | json-query shallow failed, RangeError: Maximum call stack size exceeded.
|
86 | 94 | json-query deep failed, RangeError: Maximum call stack size exceeded.
|
87 | 95 | json-query conditional failed, RangeError: Maximum call stack size exceeded.
|
88 | 96 | - jsonpath-plus:
|
89 |
| - - shallow took 2.0191 seconds. |
90 |
| - - deep took 2.0583 seconds. |
91 |
| - - conditional took 1.1441 seconds. |
| 97 | + - shallow took 2.3345 seconds. |
| 98 | + - deep took 2.472 seconds. |
| 99 | + - conditional took 3.1351 seconds. |
92 | 100 | - jsonpath:
|
93 |
| - - shallow took 5.9584 seconds. |
94 |
| - - deep took 180.8738 seconds. |
95 |
| - - conditional took 0.1097 seconds. |
| 101 | + - shallow took 8.509 seconds. |
| 102 | + - deep took 252.9623 seconds. |
| 103 | + - conditional took 0.7586 seconds. |
96 | 104 | - JSONStream:
|
97 |
| - - shallow took 16.0752 seconds. |
98 |
| - - deep took 16.9739 seconds. |
99 |
| - - conditional took 14.3877 seconds. |
100 |
| -JSONStream conditional AssertError: result should have length 2843 but instead is 0 |
| 105 | + - shallow took 54.8295 seconds. |
| 106 | + - deep took 146.2962 seconds. |
| 107 | +- oboe: |
| 108 | + - shallow took 148.8824 seconds. |
| 109 | + - deep took 216.7555 seconds. |
| 110 | +- map-filter-reduce: |
| 111 | +
|
101 | 112 |
|
102 | 113 |
|
103 | 114 | summary:
|
104 | 115 |
|
105 | 116 | smallCityLots
|
106 |
| -┌───────────────┬─────────┬────────┬─────────────┐ |
107 |
| -│ (index) │ shallow │ deep │ conditional │ |
108 |
| -├───────────────┼─────────┼────────┼─────────────┤ |
109 |
| -│ json-query │ 0.0329 │ 0.0495 │ 0.0455 │ |
110 |
| -│ jsonpath-plus │ 0.3907 │ 0.3808 │ 0.3051 │ |
111 |
| -│ jsonpath │ 1.0639 │ 6.0417 │ 0.0285 │ |
112 |
| -│ JSONStream │ 2.4209 │ 2.4758 │ 'incorrect' │ |
113 |
| -└───────────────┴─────────┴────────┴─────────────┘ |
| 117 | +┌───────────────────┬───────────────────┬───────────────────┬───────────────────┐ |
| 118 | +│ (index) │ shallow │ deep │ conditional │ |
| 119 | +├───────────────────┼───────────────────┼───────────────────┼───────────────────┤ |
| 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' │ |
| 125 | +│ map-filter-reduce │ 'not implemented' │ 'not implemented' │ 'not implemented' │ |
| 126 | +└───────────────────┴───────────────────┴───────────────────┴───────────────────┘ |
114 | 127 | mediumCityLots
|
115 |
| -┌───────────────┬─────────┬─────────┬─────────────┐ |
116 |
| -│ (index) │ shallow │ deep │ conditional │ |
117 |
| -├───────────────┼─────────┼─────────┼─────────────┤ |
118 |
| -│ json-query │ 0.0416 │ 0.0743 │ 0.0491 │ |
119 |
| -│ jsonpath-plus │ 0.7514 │ 0.8055 │ 0.6247 │ |
120 |
| -│ jsonpath │ 2.231 │ 36.6839 │ 0.0478 │ |
121 |
| -│ JSONStream │ 4.8281 │ 5.4624 │ 'incorrect' │ |
122 |
| -└───────────────┴─────────┴─────────┴─────────────┘ |
| 128 | +┌───────────────────┬───────────────────┬───────────────────┬───────────────────┐ |
| 129 | +│ (index) │ shallow │ deep │ conditional │ |
| 130 | +├───────────────────┼───────────────────┼───────────────────┼───────────────────┤ |
| 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' │ |
| 136 | +│ map-filter-reduce │ 'not implemented' │ 'not implemented' │ 'not implemented' │ |
| 137 | +└───────────────────┴───────────────────┴───────────────────┴───────────────────┘ |
123 | 138 | largeCityLots
|
124 |
| -┌───────────────┬──────────┬──────────┬─────────────┐ |
125 |
| -│ (index) │ shallow │ deep │ conditional │ |
126 |
| -├───────────────┼──────────┼──────────┼─────────────┤ |
127 |
| -│ json-query │ 'failed' │ 'failed' │ 'failed' │ |
128 |
| -│ jsonpath-plus │ 2.0191 │ 2.0583 │ 1.1441 │ |
129 |
| -│ jsonpath │ 5.9584 │ 180.8738 │ 0.1097 │ |
130 |
| -│ JSONStream │ 16.0752 │ 16.9739 │ 'incorrect' │ |
131 |
| -└───────────────┴──────────┴──────────┴─────────────┘ |
| 139 | +┌───────────────────┬───────────────────┬───────────────────┬───────────────────┐ |
| 140 | +│ (index) │ shallow │ deep │ conditional │ |
| 141 | +├───────────────────┼───────────────────┼───────────────────┼───────────────────┤ |
| 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' │ |
| 147 | +│ map-filter-reduce │ 'not implemented' │ 'not implemented' │ 'not implemented' │ |
| 148 | +└───────────────────┴───────────────────┴───────────────────┴───────────────────┘ |
132 | 149 | ```
|
0 commit comments