@@ -182,18 +182,6 @@ struct json_stats {
182182 }
183183};
184184
185- padded_string load_json (const char *filename) {
186- try {
187- verbose () << " [verbose] loading " << filename << endl;
188- padded_string json = padded_string::load (filename);
189- verbose () << " [verbose] loaded " << filename << " (" << json.size () << " bytes)" << endl;
190- return json;
191- } catch (const exception &) { // caught by reference to base
192- exit_error (string (" Could not load the file " ) + filename);
193- exit (EXIT_FAILURE); // This is not strictly necessary but removes the warning
194- }
195- }
196-
197185struct progress_bar {
198186 int max_value;
199187 int total_ticks;
@@ -253,7 +241,7 @@ const char* benchmark_stage_name(BenchmarkStage stage) {
253241
254242struct benchmarker {
255243 // JSON text from loading the file. Owns the memory.
256- const padded_string json;
244+ padded_string json;
257245 // JSON filename
258246 const char *filename;
259247 // Event collector that can be turned on to measure cycles, missed branches, etc.
@@ -272,7 +260,15 @@ struct benchmarker {
272260 event_aggregate allocate_stage;
273261
274262 benchmarker (const char *_filename, event_collector& _collector)
275- : json(load_json(_filename)), filename(_filename), collector(_collector), stats(NULL ) {}
263+ : filename(_filename), collector(_collector), stats(NULL ) {
264+ verbose () << " [verbose] loading " << filename << endl;
265+ simdjson::error_code error;
266+ std::tie (this ->json , error) = padded_string::load (filename);
267+ if (error) {
268+ exit_error (string (" Could not load the file " ) + filename);
269+ }
270+ verbose () << " [verbose] loaded " << filename << endl;
271+ }
276272
277273 ~benchmarker () {
278274 if (stats) {
0 commit comments