Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add session creation time cost to onnxruntime_perf_test output #2798

Merged
merged 1 commit into from
Jan 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions onnxruntime/test/perftest/performance_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions onnxruntime/test/perftest/performance_runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down