Fix parse benchmarker (#554)
* Fix parse benchmarker * Make CI fail when parse doesn't work
This commit is contained in:
parent
24551db0c8
commit
e4e89fe27a
|
@ -298,7 +298,7 @@ struct benchmarker {
|
|||
// Allocate document::parser
|
||||
collector.start();
|
||||
document::parser parser;
|
||||
error_code error = parser.set_capacity(json.size());
|
||||
bool alloc_ok = parser.allocate_capacity(json.size());
|
||||
event_count allocate_count = collector.end();
|
||||
allocate_stage << allocate_count;
|
||||
// Run it once to get hot buffers
|
||||
|
@ -309,14 +309,14 @@ struct benchmarker {
|
|||
}
|
||||
}
|
||||
|
||||
if (error) {
|
||||
if (!alloc_ok) {
|
||||
exit_error(string("Unable to allocate_stage ") + to_string(json.size()) + " bytes for the JSON result.");
|
||||
}
|
||||
verbose() << "[verbose] allocated memory for parsed JSON " << endl;
|
||||
|
||||
// Stage 1 (find structurals)
|
||||
collector.start();
|
||||
error = active_implementation->stage1((const uint8_t *)json.data(), json.size(), parser, false);
|
||||
error_code error = active_implementation->stage1((const uint8_t *)json.data(), json.size(), parser, false);
|
||||
event_count stage1_count = collector.end();
|
||||
stage1 << stage1_count;
|
||||
if (error) {
|
||||
|
|
|
@ -7,16 +7,27 @@
|
|||
#include <array>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define popen _popen
|
||||
#define pclose _pclose
|
||||
#endif
|
||||
|
||||
int closepipe(FILE *pipe) {
|
||||
int exit_code = pclose(pipe);
|
||||
if (exit_code != EXIT_SUCCESS) {
|
||||
std::cerr << "Error " << exit_code << " running benchmark command!" << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
};
|
||||
return exit_code;
|
||||
}
|
||||
|
||||
std::string exec(const char* cmd) {
|
||||
std::cerr << cmd << std::endl;
|
||||
std::array<char, 128> buffer;
|
||||
std::string result;
|
||||
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
|
||||
std::unique_ptr<FILE, decltype(&closepipe)> pipe(popen(cmd, "r"), closepipe);
|
||||
if (!pipe) {
|
||||
throw std::runtime_error("popen() failed!");
|
||||
}
|
||||
|
@ -43,6 +54,10 @@ double readThroughput(std::string parseOutput) {
|
|||
result += std::stod(line.substr(pos));
|
||||
numResults++;
|
||||
}
|
||||
if (numResults == 0) {
|
||||
std::cerr << "No results returned from benchmark command!" << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
return result / numResults;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue