Updating allparserscheckfile

This commit is contained in:
Daniel Lemire 2020-03-26 17:15:33 -04:00
parent 8f34e6714a
commit 8f3ddd3a73
1 changed files with 11 additions and 18 deletions

View File

@ -74,15 +74,8 @@ int main(int argc, char *argv[]) {
std::cout << p.size() << " B ";
std::cout << std::endl;
}
simdjson::ParsedJson pj;
size_t max_depth = 1024 * 4;
bool allocok = pj.allocate_capacity(p.size(), max_depth);
if (!allocok) {
std::cerr << "can't allocate memory" << std::endl;
return EXIT_FAILURE;
}
int oursreturn = json_parse(p, pj);
bool ours_correct = (oursreturn == 0); // returns 0 on success
simdjson::document::parser parser;
auto [doc, err] = parser.parse(p);
rapidjson::Document d;
@ -98,19 +91,19 @@ int main(int argc, char *argv[]) {
.is_valid();
if (just_favorites) {
printf("our parser : %s \n",
ours_correct ? "correct" : "invalid");
(err == simdjson::error_code::SUCCESS) ? "correct" : "invalid");
printf("rapid (check encoding) : %s \n",
rapid_correct_checkencoding ? "correct" : "invalid");
printf("sajson : %s \n",
sajson_correct ? "correct" : "invalid");
if (oursreturn == simdjson::DEPTH_ERROR) {
if (err == simdjson::DEPTH_ERROR) {
printf("simdjson encountered a DEPTH_ERROR, it was parametrized to "
"reject documents with depth exceeding %zu.\n",
max_depth);
parser.max_depth());
}
if ((ours_correct != rapid_correct_checkencoding) ||
if (((err == simdjson::error_code::SUCCESS) != rapid_correct_checkencoding) ||
(rapid_correct_checkencoding != sajson_correct) ||
(ours_correct != sajson_correct)) {
((err == simdjson::SUCCESS) != sajson_correct)) {
printf("WARNING: THEY DISAGREE\n\n");
return EXIT_FAILURE;
}
@ -137,11 +130,11 @@ int main(int argc, char *argv[]) {
if (tokens == nullptr) {
printf("Failed to alloc memory for jsmn\n");
} else {
jsmn_parser parser;
jsmn_init(&parser);
jsmn_parser jsmnparser;
jsmn_init(&jsmnparser);
memcpy(buffer, p.data(), p.size());
buffer[p.size()] = '\0';
int r = jsmn_parse(&parser, buffer, p.size(), tokens.get(), p.size());
int r = jsmn_parse(&jsmnparser, buffer, p.size(), tokens.get(), p.size());
tokens = nullptr;
jsmn_correct = (r > 0);
}
@ -163,7 +156,7 @@ int main(int argc, char *argv[]) {
delete json_cpp_reader;
printf("our parser : %s \n",
ours_correct ? "correct" : "invalid");
(err == simdjson::error_code::SUCCESS) ? "correct" : "invalid");
printf("rapid : %s \n",
rapid_correct ? "correct" : "invalid");
printf("rapid (check encoding) : %s \n",