-
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.
- Loading branch information
1 parent
eda88a0
commit 40ac4bd
Showing
3 changed files
with
55 additions
and
0 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