Skip to content
This repository was archived by the owner on Nov 14, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
28e80bf
Make JsonPathError implement std::error::Error so it can be encapsula…
yoav-steinberg Jul 6, 2020
6b7ad5d
fix clippy
Mar 2, 2021
2d8e534
Move env-logger to dev-dependencies
Mar 8, 2021
86bedfb
fix clippy
freestrings Jun 3, 2021
b012cbe
remove array_tools
freestrings Jun 3, 2021
fd6dbd6
fix clippy
freestrings Jun 3, 2021
bf90185
version bump 0.3.0
freestrings Jun 3, 2021
fbf7180
Merge branch 'test-versionbump'
freestrings Jun 3, 2021
c3b9734
Fix crash on removing multiple elements from an array
Jun 28, 2021
fa706e8
fix clippy
freestrings Jun 30, 2021
3aa73c6
Start refactoring to start improving performance. Related #72
freestrings Aug 1, 2021
54a8240
add benchmark script
freestrings Aug 2, 2021
f42c71e
Remove useless iteration in TokenReader
freestrings Aug 2, 2021
241c74a
turn off 'deprecated' warning
freestrings Aug 2, 2021
e69449b
fix clippy
freestrings Aug 2, 2021
ff4ed1c
rewrite small logic
freestrings Aug 2, 2021
bc06622
fix compare
freestrings Aug 5, 2021
d7d22a7
"Cmp" improvement
freestrings Aug 6, 2021
aea5722
add massif script. Related #72
freestrings Aug 7, 2021
33a9f99
attach old flame.svg
freestrings Aug 8, 2021
a1b323a
fix #50. unconsumed filter token
freestrings Aug 9, 2021
1d7bada
close #50
freestrings Sep 7, 2021
1a84c5a
fix clippy
freestrings Sep 7, 2021
b87e75f
pull in upstream changes, resolve conflicts, apply required tweaks fo…
lfarrel6 May 4, 2022
2a58321
add tests for error in replace with handler for jsonpath selectors
lfarrel6 May 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
!.idea/runConfigurations/
/target/
Cargo.lock
callgrind.out.*
callgrind.out.*
perf.data
perf.data.*
massif.out.*
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@ keywords = ["jsonpath", "json", "webassembly", "lua", "query"]
categories = ['wasm', "parser-implementations", "api-bindings"]

repository = "https://github.com/freestrings/jsonpath"
documentation = "https://docs.rs/jsonpath_lib/0.2.6/jsonpath_lib"
documentation = "https://docs.rs/jsonpath_lib/0.3.0/jsonpath_lib"
license = "MIT"

[badges]
travis-ci = { repository = "freestrings/jsonpath", branch = "master" }

[dependencies]
log = "0.4"
env_logger = "0.7"
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", features = ["preserve_order"] }
array_tool = "1.0.3"

[dev-dependencies]
env_logger = "0.8"

[lib]
name = "jsonpath_lib"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ assert_eq!(ret[0], person);

</details>

<details><summary><b>Rust - jsonpath::Compiled::compile(jsonpath: &str)</b></summary>
<details><summary><b>Rust - jsonpath::PathCompiled::compile(jsonpath: &str)</b></summary>

```rust
let template = jsonpath::Compiled::compile("$..friends[0]").unwrap();
let template = jsonpath::PathCompiled::compile("$..friends[0]").unwrap();

let json_obj = json!({
"school": {
Expand Down
5 changes: 4 additions & 1 deletion benchmark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ bencher = "0.1.5"

[[bin]]
name = "jsonpath_lib_benches"
path = "src/main.rs"
path = "src/main.rs"

[profile.release]
debug = true
52 changes: 52 additions & 0 deletions benchmark/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# 프레임그래프 생성 방법

## 사전 준비
1. perf 설치
2. flamegraph 다운로드
- https://github.com/brendangregg/FlameGraph
3. rust-unmangle 다운로드
- https://github.com/Yamakaky/rust-unmangle
- 실행 파일로 만들고
4. PATH에 추가

```bash
export PATH=/home/han/Documents/FlameGraph:$PATH
export PATH=/home/han/Documents/rust-unmangle:$PATH
```

5. 설정 추가

```bash
sudo sh -c 'echo 1 >/proc/sys/kernel/perf_event_paranoid'
sudo sh -c 'echo 0 >/proc/sys/kernel/kptr_restrict'
```

## 실행

> ./gen_flamegraph.sh

# 발그라인드 생성 방법

## 사전 준비
1. valgrind 설치
> sudo apt-get install valgrind

2. massif-visualizer
> sudo apt-get install massif-visualizer

## 실행

> ./gen_valgrind.sh
> massif-visualizer 실행 #massif.out.xxx 읽기


## call 그래프 보려면

2. kcachegrind 설치
> sudo apt-get install kcachegrind

## 실행

> ./gen_valgrind.sh # --tool=callgrind --dump-instr=yes --collect-jumps=yes --simulate-cache=yes
> kcachegrind #callgrind.out.xxx 읽기
>
5 changes: 0 additions & 5 deletions benchmark/bench_bin/.gitignore

This file was deleted.

7 changes: 0 additions & 7 deletions benchmark/bench_bin/Cargo.toml

This file was deleted.

8 changes: 0 additions & 8 deletions benchmark/bench_bin/bench.sh

This file was deleted.

48 changes: 0 additions & 48 deletions benchmark/bench_bin/src/main.rs

This file was deleted.

23 changes: 12 additions & 11 deletions benchmark/benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ extern crate serde_json;
extern crate test;

use std::io::Read;
use std::rc::Rc;

use jsonpath::{JsonSelector, JsonSelectorMut, PathParser};
use serde::Deserialize;
use serde_json::Value;

use jsonpath::{SelectorMut, Selector};

use self::test::Bencher;

fn read_json(path: &str) -> String {
Expand Down Expand Up @@ -79,7 +79,7 @@ fn bench_select_as_str(b: &mut Bencher) {
#[bench]
fn bench_compile(b: &mut Bencher) {
let json = get_json();
let template = jsonpath::Compiled::compile(get_path()).unwrap();
let template = jsonpath::PathCompiled::compile(get_path()).unwrap();
b.iter(move || {
for _ in 1..100 {
let _ = template.select(&json).unwrap();
Expand Down Expand Up @@ -109,8 +109,8 @@ fn bench_select_as(b: &mut Bencher) {
#[bench]
fn bench_delete(b: &mut Bencher) {
let json = get_json();
let mut selector = SelectorMut::default();
let _ = selector.str_path(get_path());
let parser = PathParser::compile(get_path()).unwrap();
let mut selector = JsonSelectorMut::new(parser);

b.iter(move || {
for _ in 1..100 {
Expand All @@ -123,15 +123,16 @@ fn bench_delete(b: &mut Bencher) {
fn bench_select_to_compare_with_delete(b: &mut Bencher) {
let json = &get_json();

let mut selector = Selector::default();
let _ = selector.str_path(get_path());
let parser = Rc::new(PathParser::compile(get_path()).unwrap());

b.iter(move || {
for _ in 1..100 {
let json = json.clone();
let mut s = Selector::default();
let _ = s.compiled_path(selector.node_ref().unwrap()).value(&json);
let _ = s.select();
let mut s = JsonSelector::new_ref(Rc::clone(&parser));
let _ = s.value(&json);
let r = s.select();
if r.is_err() {
panic!()
}
}
});
}
4 changes: 2 additions & 2 deletions benchmark/benches/bench_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ fn _selector(b: &mut Bencher, index: usize) {
let json = get_json();
b.iter(move || {
for _ in 1..100 {
let mut selector = jsonpath::Selector::default();
let _ = selector.str_path(get_path(index));
let parser = jsonpath::PathParser::compile(get_path(index)).unwrap();
let mut selector = jsonpath::JsonSelector::new(parser);
selector.value(&json);
let r = selector.select();
if r.is_err() {
Expand Down
Loading