-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
get rid of JsonPathFinder and Boxes (#58)
* Revert "61 regex perf (#62)" This reverts commit a07c7b6. * try to get rid of JsonPathFinder and Boxes - JsonPathFinder interface does not really benefit from storing the json or path internally - trying to get rid of the Box<> that is used inside of JsonPathFinder * some clippy fixes * add benches for find slicing equal bench with reuse time: [510.30 ns 512.16 ns 514.26 ns] equal bench without reuse time: [21.436 µs 21.456 µs 21.479 µs] regex bench with reuse time: [58.875 µs 58.925 µs 58.975 µs] regex bench without reuse time: [85.324 µs 85.416 µs 85.517 µs] JsonPathInst generation time: [23.988 µs 24.019 µs 24.052 µs]
- Loading branch information
Showing
13 changed files
with
358 additions
and
669 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,48 @@ | ||
* **`0.1.0`** | ||
* Initial implementation | ||
* **`0.1.1`** | ||
* Technical improvements | ||
* **`0.1.2`** | ||
* added a trait to obtain the result from value | ||
* added a method to get the cloned as Value | ||
* change the name of the general method* | ||
* **`0.1.4`** | ||
* add an ability to use references instead of values | ||
* fix some clippy issues | ||
* **`0.1.5`** | ||
* correct grammar for `$.[..]` | ||
* **`0.1.6`** | ||
* add logical OR and logical And to filters | ||
* fix bugs with objects in filters | ||
* add internal macros to generate path objects | ||
* **`0.2.0`** | ||
* add json path value as a result for the library | ||
* add functions (size) | ||
* change a logical operator `size` into function `size()` | ||
* **`0.2.1`** | ||
* changed the contract for length() function. | ||
* **`0.2.2`** | ||
* add ..* | ||
* **`0.2.5`** | ||
* build for tags | ||
* **`0.2.6`** | ||
* make parser mod public | ||
* **`0.3.0`** | ||
* introduce the different behaviour for empty results and non-existing result | ||
* **`0.3.2`** | ||
* make jsonpath inst cloneable. | ||
* **`0.3.3`** | ||
* fix a bug with the logical operators | ||
* **`0.3.4`** | ||
* add a result as a path | ||
* **`0.3.5`** | ||
* add `!` negation operation in filters | ||
* allow using () in filters | ||
* **`0.5`** | ||
* add config for jsonpath | ||
* add an option to add a regex cache for boosting performance | ||
* **`0.5.1`** | ||
* add double quotes for the expressions (before it was only possible to use single quotes) | ||
* add Debug on the JsonPathFinder | ||
|
||
|
||
- **`0.1.0`** | ||
- Initial implementation | ||
- **`0.1.1`** | ||
- Technical improvements | ||
- **`0.1.2`** | ||
- added a trait to obtain the result from value | ||
- added a method to get the cloned as Value | ||
- change the name of the general method\* | ||
- **`0.1.4`** | ||
- add an ability to use references instead of values | ||
- fix some clippy issues | ||
- **`0.1.5`** | ||
- correct grammar for `$.[..]` | ||
- **`0.1.6`** | ||
- add logical OR and logical And to filters | ||
- fix bugs with objects in filters | ||
- add internal macros to generate path objects | ||
- **`0.2.0`** | ||
- add json path value as a result for the library | ||
- add functions (size) | ||
- change a logical operator `size` into function `size()` | ||
- **`0.2.1`** | ||
- changed the contract for length() function. | ||
- **`0.2.2`** | ||
- add ..\* | ||
- **`0.2.5`** | ||
- build for tags | ||
- **`0.2.6`** | ||
- make parser mod public | ||
- **`0.3.0`** | ||
- introduce the different behaviour for empty results and non-existing result | ||
- **`0.3.2`** | ||
- make jsonpath inst cloneable. | ||
- **`0.3.3`** | ||
- fix a bug with the logical operators | ||
- **`0.3.4`** | ||
- add a result as a path | ||
- **`0.3.5`** | ||
- add `!` negation operation in filters | ||
- allow using () in filters | ||
- **`0.5`** | ||
- add config for jsonpath | ||
- add an option to add a regex cache for boosting performance | ||
- **`0.5.1`** | ||
- add double quotes for the expressions (before it was only possible to use single quotes) | ||
- add Debug on the JsonPathFinder | ||
- **`0.6`** | ||
- allow to reuse regex, that improves performance without needing an internal cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use jsonpath_rust::{JsonPathInst, JsonPathQuery}; | ||
use serde_json::json; | ||
use std::str::FromStr; | ||
|
||
struct SearchData { | ||
json: serde_json::Value, | ||
path: JsonPathInst, | ||
} | ||
|
||
const PATH: &'static str = "$.[?(@.author == 'abcd(Rees)')]"; | ||
|
||
fn equal_perf_test_with_reuse(cfg: &SearchData) { | ||
let _v = jsonpath_rust::find(&cfg.path, &cfg.json); | ||
} | ||
|
||
fn equal_perf_test_without_reuse() { | ||
let json = Box::new(json!({ | ||
"author":"abcd(Rees)", | ||
})); | ||
|
||
let _v = json.path(PATH).expect("the path is correct"); | ||
} | ||
|
||
pub fn criterion_benchmark(c: &mut Criterion) { | ||
let data = SearchData { | ||
json: json!({ | ||
"author":"abcd(Rees)", | ||
}), | ||
path: JsonPathInst::from_str(PATH).unwrap(), | ||
}; | ||
c.bench_function("equal bench with reuse", |b| { | ||
b.iter(|| equal_perf_test_with_reuse(&data)) | ||
}); | ||
c.bench_function("equal bench without reuse", |b| { | ||
b.iter(|| equal_perf_test_without_reuse()) | ||
}); | ||
} | ||
|
||
criterion_group!(benches, criterion_benchmark); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use jsonpath_rust::{JsonPathInst, JsonPathQuery}; | ||
use serde_json::json; | ||
use std::str::FromStr; | ||
|
||
struct SearchData { | ||
json: serde_json::Value, | ||
path: JsonPathInst, | ||
} | ||
|
||
const PATH: &'static str = "$.[?(@.author ~= '.*(?i)d\\(Rees\\)')]"; | ||
|
||
fn regex_perf_test_with_reuse(cfg: &SearchData) { | ||
let _v = jsonpath_rust::find(&cfg.path, &cfg.json); | ||
} | ||
|
||
fn regex_perf_test_without_reuse() { | ||
let json = Box::new(json!({ | ||
"author":"abcd(Rees)", | ||
})); | ||
|
||
let _v = json.path(PATH).expect("the path is correct"); | ||
} | ||
|
||
fn json_path_inst_compiling() { | ||
let _v = JsonPathInst::from_str(PATH).unwrap(); | ||
} | ||
|
||
pub fn criterion_benchmark(c: &mut Criterion) { | ||
let data = SearchData { | ||
json: json!({ | ||
"author":"abcd(Rees)", | ||
}), | ||
path: JsonPathInst::from_str(PATH).unwrap(), | ||
}; | ||
c.bench_function("regex bench with reuse", |b| { | ||
b.iter(|| regex_perf_test_with_reuse(&data)) | ||
}); | ||
c.bench_function("regex bench without reuse", |b| { | ||
b.iter(|| regex_perf_test_without_reuse()) | ||
}); | ||
c.bench_function("JsonPathInst generation", |b| { | ||
b.iter(|| json_path_inst_compiling()) | ||
}); | ||
} | ||
|
||
criterion_group!(benches, criterion_benchmark); | ||
criterion_main!(benches); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.