| 37 | } // namespace |
| 38 | |
| 39 | int main(int argc, char ** argv) { |
| 40 | try { |
| 41 | const auto model_path = required_path(argc, argv, "--model"); |
| 42 | const int warmup = arg_int(argc, argv, "--warmup", 1); |
| 43 | const int iterations = arg_int(argc, argv, "--iterations", 3); |
| 44 | |
| 45 | const auto registry = engine::runtime::make_default_registry(); |
| 46 | |
| 47 | for (int i = 0; i < warmup; ++i) { |
| 48 | auto model = registry.load(model_path); |
| 49 | (void)model; |
| 50 | } |
| 51 | |
| 52 | std::vector<double> ms_values; |
| 53 | ms_values.reserve(static_cast<size_t>(iterations)); |
| 54 | for (int i = 0; i < iterations; ++i) { |
| 55 | const auto start = std::chrono::steady_clock::now(); |
| 56 | auto model = registry.load(model_path); |
| 57 | const auto end = std::chrono::steady_clock::now(); |
| 58 | (void)model; |
| 59 | const double ms = std::chrono::duration<double, std::milli>(end - start).count(); |
| 60 | ms_values.push_back(ms); |
| 61 | std::cout << "load_ms[" << i << "]=" << std::fixed << std::setprecision(6) << ms << "\n"; |
| 62 | } |
| 63 | |
| 64 | double sum = 0.0; |
| 65 | for (const double value : ms_values) { |
| 66 | sum += value; |
| 67 | } |
| 68 | const double avg = ms_values.empty() ? 0.0 : sum / static_cast<double>(ms_values.size()); |
| 69 | std::cout << "load_ms.avg=" << std::fixed << std::setprecision(6) << avg << "\n"; |
| 70 | return 0; |
| 71 | } catch (const std::exception & e) { |
| 72 | std::cerr << "model_load_bench failed: " << e.what() << "\n"; |
| 73 | return 1; |
| 74 | } |
| 75 | } |
nothing calls this directly
no test coverage detected