mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-27 20:02:15 +00:00
add session creation time cost. (#2798)
This commit is contained in:
parent
32c5e76a16
commit
1978376e1e
2 changed files with 14 additions and 7 deletions
|
|
@ -69,15 +69,17 @@ Status PerformanceRunner::Run() {
|
|||
performance_result_.average_CPU_usage = p_ICPUUsage->GetUsage();
|
||||
performance_result_.peak_workingset_size = utils::GetPeakWorkingSetSize();
|
||||
|
||||
std::chrono::duration<double> session_create_duration = session_create_end_ - session_create_start_;
|
||||
// TODO: end profiling
|
||||
// if (!performance_test_config_.run_config.profile_file.empty()) session_object->EndProfiling();
|
||||
std::chrono::duration<double> duration = performance_result_.end_ - performance_result_.start_;
|
||||
std::chrono::duration<double> inference_duration = performance_result_.end_ - performance_result_.start_;
|
||||
|
||||
std::cout << "Total time cost:" << performance_result_.total_time_cost << std::endl // sum of time taken by each request
|
||||
<< "Total iterations:" << performance_result_.time_costs.size() << std::endl
|
||||
<< "Average time cost:" << performance_result_.total_time_cost / performance_result_.time_costs.size() * 1000 << " ms" << std::endl
|
||||
std::cout << "Session creation time cost:" << session_create_duration.count() << " s" << std::endl
|
||||
<< "Total inference time cost:" << performance_result_.total_time_cost << " s" << std::endl // sum of time taken by each request
|
||||
<< "Total inference requests:" << performance_result_.time_costs.size() << std::endl
|
||||
<< "Average inference time cost:" << performance_result_.total_time_cost / performance_result_.time_costs.size() * 1000 << " ms" << std::endl
|
||||
// Time between start and end of run. Less than Total time cost when running requests in parallel.
|
||||
<< "Total run time:" << duration.count() << " s" << std::endl;
|
||||
<< "Total inference run time:" << inference_duration.count() << " s" << std::endl;
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
|
|
@ -191,8 +193,11 @@ static TestSession* CreateSession(Ort::Env& env, std::random_device& rd,
|
|||
}
|
||||
PerformanceRunner::PerformanceRunner(Ort::Env& env, const PerformanceTestConfig& test_config, std::random_device& rd)
|
||||
: performance_test_config_(test_config),
|
||||
test_model_info_(CreateModelInfo(test_config)),
|
||||
session_(CreateSession(env, rd, test_config, test_model_info_)) {}
|
||||
test_model_info_(CreateModelInfo(test_config)) {
|
||||
session_create_start_ = std::chrono::high_resolution_clock::now();
|
||||
session_.reset(CreateSession(env, rd, test_config, test_model_info_));
|
||||
session_create_end_ = std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
|
||||
PerformanceRunner::~PerformanceRunner() = default;
|
||||
|
||||
|
|
|
|||
|
|
@ -132,6 +132,8 @@ class PerformanceRunner {
|
|||
}
|
||||
|
||||
private:
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> session_create_start_;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> session_create_end_;
|
||||
PerformanceResult performance_result_;
|
||||
PerformanceTestConfig performance_test_config_;
|
||||
TestModelInfo* test_model_info_;
|
||||
|
|
|
|||
Loading…
Reference in a new issue