mirror of
https://github.com/simdjson/simdjson
synced 2026-06-08 17:27:07 +00:00
nit
This commit is contained in:
@@ -85,6 +85,15 @@ void wildcard_bracket_element_properties_address() {
|
||||
print_result(values);
|
||||
}
|
||||
|
||||
void wildcard_bracket_element_properties_address_bracket() {
|
||||
// selects all address properties - $["address"].*
|
||||
std::cout << "Result for $['address'][*]" << "\n";
|
||||
auto result = parsed_json.at_path_with_wildcard("$['address'][*]");
|
||||
|
||||
std::vector<simdjson::dom::element> values = result.value();
|
||||
print_result(values);
|
||||
}
|
||||
|
||||
void wildcard_dot_element_properties_phoneNumbers() {
|
||||
// selects all phoneNumbers properties - $.phoneNumbers.*
|
||||
std::cout << "Result for $.phoneNumbers.*" << "\n";
|
||||
@@ -108,8 +117,8 @@ int main(int argc, char **argv) {
|
||||
wildcard_bracket_top_level_elements();
|
||||
wildcard_dot_element_properties_address();
|
||||
wildcard_bracket_element_properties_address();
|
||||
wildcard_bracket_element_properties_address_bracket();
|
||||
wildcard_dot_element_properties_phoneNumbers();
|
||||
wildcard_bracket_element_nested_properties_streetAddress();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -115,6 +115,26 @@ void BM_wildcard_bracket_element_properties_address(benchmark::State &state) {
|
||||
|
||||
BENCHMARK(BM_wildcard_bracket_element_properties_address)->UseManualTime();
|
||||
|
||||
void BM_wildcard_bracket_element_properties_address_bracket(benchmark::State &state) {
|
||||
for (auto _ : state) {
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
|
||||
// selects all address properties - $["address"][*]
|
||||
auto result = parsed_json.at_path_with_wildcard("$['address'][*]");
|
||||
|
||||
std::vector<simdjson::dom::element> values = result.value();
|
||||
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
|
||||
auto elapsed_seconds =
|
||||
std::chrono::duration_cast<std::chrono::duration<double>>(end - start);
|
||||
|
||||
state.SetIterationTime(elapsed_seconds.count());
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(BM_wildcard_bracket_element_properties_address_bracket)->UseManualTime();
|
||||
|
||||
void BM_wildcard_dot_element_properties_phoneNumbers(benchmark::State &state) {
|
||||
for (auto _ : state) {
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
|
||||
@@ -269,6 +269,10 @@ object::at_path_with_wildcard(std::string_view json_path) const noexcept {
|
||||
key += json_path[i];
|
||||
++i;
|
||||
}
|
||||
} else if (json_path[i] == '[' && json_path[i + 1] == '*' &&
|
||||
json_path[i + 2] == ']') {
|
||||
key += json_path[i + 1];
|
||||
i += 2;
|
||||
}
|
||||
|
||||
std::vector<element> child_values;
|
||||
|
||||
Reference in New Issue
Block a user