MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / main

Function main

tests/perf/model_perf.cpp:494–598  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

492} // namespace
493
494int main(int argc, char ** argv) {
495 try {
496 std::cout.setf(std::ios::unitbuf);
497 const std::filesystem::path repo_root = std::filesystem::current_path();
498 const std::filesystem::path perf_cases_path = optional_arg(
499 argc,
500 argv,
501 "--perf-cases",
502 "tests/perf/model_perf_cases.json");
503 const std::filesystem::path path_cases_path = optional_arg(
504 argc,
505 argv,
506 "--request-cases",
507 "tests/perf/model_perf_request_cases.json");
508 const std::string backend_name = optional_arg(argc, argv, "--backend", "cuda");
509 const int device = parse_int_arg(argc, argv, "--device", 0);
510 const int threads = parse_int_arg(argc, argv, "--threads", 1);
511 if (threads <= 0) {
512 throw std::runtime_error("--threads must be positive");
513 }
514#ifdef _OPENMP
515 omp_set_num_threads(threads);
516#endif
517 const auto selected_id = find_arg(argc, argv, "--id");
518 const auto summary_out_arg = find_arg(argc, argv, "--summary-out");
519 const auto output_root = summary_out_arg.has_value()
520 ? std::filesystem::path(*summary_out_arg).parent_path()
521 : repo_root / "build" / "logs" / "perf" /
522 ("cpp_" + lower_ascii(backend_name) + "_" + make_timestamp());
523 std::filesystem::create_directories(output_root);
524
525 const auto perf_root = engine::io::json::parse_file(perf_cases_path);
526 const auto path_root = engine::io::json::parse_file(path_cases_path);
527 auto registry = engine::runtime::make_default_registry();
528 const auto backend_type = parse_backend(backend_name);
529
530 std::vector<CaseSummary> summaries;
531 for (const auto & perf_case_value : perf_root.require("cases").as_array()) {
532 const auto perf_case = parse_perf_case(perf_case_value);
533 if (selected_id.has_value() && *selected_id != perf_case.id) {
534 continue;
535 }
536 const auto & case_value = require_case(path_root, perf_case.case_id);
537 const auto & request_value = require_request(case_value, perf_case.request_id);
538 const auto load_request = build_load_request(case_value, repo_root);
539 const auto task_spec = build_task_spec(case_value);
540 const auto session_options = build_session_options(case_value, backend_type, device, threads);
541 const auto request = minitts::cli::build_request_from_json(request_value, repo_root);
542
543 const auto temp_dir = output_root / (perf_case.id + "_warmup");
544 std::filesystem::create_directories(temp_dir);
545 engine::runtime::TaskRequest warmup_request;
546 if (perf_case.warmup_request_id.has_value()) {
547 warmup_request = minitts::cli::build_request_from_json(
548 require_request(case_value, *perf_case.warmup_request_id),
549 repo_root);
550 } else {
551 warmup_request = minitts::cli::build_request_from_json(

Callers

nothing calls this directly

Calls 15

optional_argFunction · 0.85
make_timestampFunction · 0.85
parse_fileFunction · 0.85
make_default_registryFunction · 0.85
parse_perf_caseFunction · 0.85
require_requestFunction · 0.85
build_load_requestFunction · 0.85
build_task_specFunction · 0.85
build_session_optionsFunction · 0.85
build_request_from_jsonFunction · 0.85
case_summary_jsonFunction · 0.85
strMethod · 0.80

Tested by

no test coverage detected