-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
json_find: make implementation much shorter (#18)
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
- Loading branch information
1 parent
b1e0922
commit d041a72
Showing
4 changed files
with
85 additions
and
53 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
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,38 @@ | ||
use codspeed_criterion_compat::{criterion_group, criterion_main, Bencher, Criterion}; | ||
|
||
use datafusion_common::ScalarValue; | ||
use datafusion_expr::ColumnarValue; | ||
use datafusion_functions_json::udfs::{json_contains_udf, json_get_str_udf}; | ||
|
||
fn bench_json_contains(b: &mut Bencher) { | ||
let json_contains = json_contains_udf(); | ||
let args = &[ | ||
ColumnarValue::Scalar(ScalarValue::Utf8(Some( | ||
r#"{"a": {"aa": "x", "ab: "y"}, "b": []}"#.to_string(), | ||
))), | ||
ColumnarValue::Scalar(ScalarValue::Utf8(Some("a".to_string()))), | ||
ColumnarValue::Scalar(ScalarValue::Utf8(Some("aa".to_string()))), | ||
]; | ||
|
||
b.iter(|| json_contains.invoke(args).unwrap()); | ||
} | ||
|
||
fn bench_json_get_str(b: &mut Bencher) { | ||
let json_get_str = json_get_str_udf(); | ||
let args = &[ | ||
ColumnarValue::Scalar(ScalarValue::Utf8(Some( | ||
r#"{"a": {"aa": "x", "ab: "y"}, "b": []}"#.to_string(), | ||
))), | ||
ColumnarValue::Scalar(ScalarValue::Utf8(Some("a".to_string()))), | ||
ColumnarValue::Scalar(ScalarValue::Utf8(Some("aa".to_string()))), | ||
]; | ||
|
||
b.iter(|| json_get_str.invoke(args).unwrap()); | ||
} | ||
fn criterion_benchmark(c: &mut Criterion) { | ||
c.bench_function("json_contains", bench_json_contains); | ||
c.bench_function("json_get_str", bench_json_get_str); | ||
} | ||
|
||
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
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