MCPcopy Create free account
hub / github.com/BYVoid/OpenCC / ParseMeasuredResult

Function ParseMeasuredResult

src/benchmark/Performance.cpp:481–511  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

479};
480
481MeasuredResult ParseMeasuredResult(const std::string& path) {
482 const std::string content = ReadFile(path);
483 JSONDocument document;
484 document.Parse(content.c_str());
485 if (document.HasParseError() || !document.IsObject()) {
486 throw InvalidFormat("Error parsing measured result JSON");
487 }
488
489 MeasuredResult result;
490 if (document.HasMember("load_ms") && document["load_ms"].IsNumber()) {
491 result.loadMs = document["load_ms"].GetDouble();
492 }
493 if (document.HasMember("convert_ms") && document["convert_ms"].IsNumber()) {
494 result.convertMs = document["convert_ms"].GetDouble();
495 }
496 if (document.HasMember("write_ms") && document["write_ms"].IsNumber()) {
497 result.writeMs = document["write_ms"].GetDouble();
498 }
499 if (document.HasMember("total_ms") && document["total_ms"].IsNumber()) {
500 result.totalMs = document["total_ms"].GetDouble();
501 }
502 if (document.HasMember("input_bytes") && document["input_bytes"].IsUint64()) {
503 result.inputBytes = static_cast<size_t>(document["input_bytes"].GetUint64());
504 }
505 if (document.HasMember("output_bytes") &&
506 document["output_bytes"].IsUint64()) {
507 result.outputBytes =
508 static_cast<size_t>(document["output_bytes"].GetUint64());
509 }
510 return result;
511}
512
513void RunCommandLineConversion(const BenchmarkConfig& config,
514 const std::string& input_path,

Callers 2

BM_CommandLineLongTextFunction · 0.85
BM_CommandLineFunction · 0.85

Calls 4

HasMemberMethod · 0.80
ReadFileFunction · 0.70
ParseMethod · 0.45
HasParseErrorMethod · 0.45

Tested by

no test coverage detected