JSONPath-Plus / JSONPath

A fork of JSONPath from http://goessner.net/articles/JsonPath/
Other
958 stars 169 forks source link

perf: optimize walk method by 10-34% #179

Closed jacobroschen closed 1 year ago

jacobroschen commented 1 year ago

The walk method now only takes the parameters it actually needs, which gives a performance bump to due to less copying & passing of parameters to the walk method.

Running json-querying-performance-testing, this change produced the following speed improvements compared to v7.1.0.

smallCityLots
┌───────────────┬───────────┬────────────┬─────────────┐
│    (index)    │  shallow  │    deep    │ conditional │
├───────────────┼───────────┼────────────┼─────────────┤
│ jsonpath-plus │   0.0641  │   0.3249   │   0.1199    │
├───────────────┼───────────┼────────────┼─────────────┤
│  jsonpath-pr  │   0.0439  │   0.2930   │   0.0850    │
├───────────────┼───────────┼────────────┼─────────────┤
│  Time Delta   │  -0.0202  │  -0.0319   │  -0.0349    │
├───────────────┼───────────┼────────────┼─────────────┤
│   % Change    │ -31.5133% │  -9.8184%  │ -29.1076%   │
└───────────────┴───────────┴────────────┴─────────────┘
mediumCityLots
┌───────────────┬───────────┬────────────┬─────────────┐
│    (index)    │  shallow  │    deep    │ conditional │
├───────────────┼───────────┼────────────┼─────────────┤
│ jsonpath-plus │   0.092   │   0.6739   │   0.2409    │
├───────────────┼───────────┼────────────┼─────────────┤
│  jsonpath-pr  │   0.0659  │   0.5443   │   0.1672    │
├───────────────┼───────────┼────────────┼─────────────┤
│  Time Delta   │  -0.0261  │  -0.1296   │  -0.0737    │
├───────────────┼───────────┼────────────┼─────────────┤
│   % Change    │ -28.3696% │ -19.2313%  │ -30.5936%   │
└───────────────┴───────────┴────────────┴─────────────┘
largeCityLots
┌───────────────┬───────────┬────────────┬─────────────┐
│    (index)    │  shallow  │    deep    │ conditional │
├───────────────┼───────────┼────────────┼─────────────┤
│ jsonpath-plus │   0.1910  │   1.8946   │   0.4900    │
├───────────────┼───────────┼────────────┼─────────────┤
│  jsonpath-pr  │   0.1347  │   1.6538   │   0.3230    │
├───────────────┼───────────┼────────────┼─────────────┤
│  Time Delta   │   0.0563  │  -0.2408   │  -0.1670    │
├───────────────┼───────────┼────────────┼─────────────┤
│   % Change    │ -29.4764% │ -12.7098%  │ -34.0816%   │
└───────────────┴───────────┴────────────┴─────────────┘

PR description

Checklist

jacobroschen commented 1 year ago

@brettz9 Once this is approved & merged I would appreciate if you could cut a new release.

brettz9 commented 1 year ago

Go ahead and merge if you have no further last minute changes. I can then look to release.