MCPcopy Create free account
hub / github.com/Compaile/ctrack / load_baseline

Function load_baseline

benchmark/ctrack_benchmark.cpp:552–627  ·  view source on GitHub ↗

Load baseline from file

Source from the content-addressed store, hash-verified

550
551// Load baseline from file
552bool load_baseline(BaselineData &data)
553{
554 std::ifstream file(g_config.baseline_file);
555 if (!file)
556 {
557 return false;
558 }
559
560 // Simple JSON parsing (production code would use a proper JSON library)
561 std::string line;
562 while (std::getline(file, line))
563 {
564 if (line.find("\"accuracy_error_percent\":") != std::string::npos)
565 {
566 size_t pos = line.find(": ") + 2;
567 size_t end = line.find(",", pos);
568 data.accuracy_error_percent = std::stod(line.substr(pos, end - pos));
569 }
570 else if (line.find("\"accuracy_error_ms_per_event\":") != std::string::npos)
571 {
572 size_t pos = line.find(": ") + 2;
573 size_t end = line.find(",", pos);
574 data.accuracy_error_ms_per_event = std::stod(line.substr(pos, end - pos));
575 }
576 else if (line.find("\"overhead_percent\":") != std::string::npos)
577 {
578 size_t pos = line.find(": ") + 2;
579 size_t end = line.find(",", pos);
580 data.overhead_percent = std::stod(line.substr(pos, end - pos));
581 }
582 else if (line.find("\"overhead_ms\":") != std::string::npos)
583 {
584 size_t pos = line.find(": ") + 2;
585 size_t end = line.find(",", pos);
586 data.overhead_ms = std::stod(line.substr(pos, end - pos));
587 }
588 else if (line.find("\"overhead_ns_per_event\":") != std::string::npos)
589 {
590 size_t pos = line.find(": ") + 2;
591 size_t end = line.find(",", pos);
592 data.overhead_ns_per_event = std::stod(line.substr(pos, end - pos));
593 }
594 else if (line.find("\"memory_bytes_per_event\":") != std::string::npos)
595 {
596 size_t pos = line.find(": ") + 2;
597 size_t end = line.find(",", pos);
598 data.memory_bytes_per_event = std::stod(line.substr(pos, end - pos));
599 }
600 else if (line.find("\"calculation_time_ms\":") != std::string::npos)
601 {
602 size_t pos = line.find(": ") + 2;
603 size_t end = line.find(",", pos);
604 data.calculation_time_ms = std::stod(line.substr(pos, end - pos));
605 }
606 else if (line.find("\"peak_calc_memory_mb\":") != std::string::npos)
607 {
608 size_t pos = line.find(": ") + 2;
609 size_t end = line.find(",", pos);

Callers 1

compare_with_baselineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected