提交 1fa1fce4 编写于 作者: D dolphin8

use printf to replace std::cout for better format control

上级 ff6ce4e7
...@@ -360,7 +360,7 @@ std::shared_ptr<framework::Tensor> Executor<Dtype, P>::Predict( ...@@ -360,7 +360,7 @@ std::shared_ptr<framework::Tensor> Executor<Dtype, P>::Predict(
std::cout << "====================[ profile ]======================\n"; std::cout << "====================[ profile ]======================\n";
using prof_t = std::pair<std::string, clock_t>; using prof_t = std::pair<std::string, clock_t>;
std::vector<prof_t> _tprofile(_profile.begin(), _profile.end()); std::vector<prof_t> _tprofile(_profile.begin(), _profile.end());
clock_t _ptotal; clock_t _ptotal = 0;
for (auto const &p : _tprofile) { for (auto const &p : _tprofile) {
_ptotal += p.second; _ptotal += p.second;
} }
...@@ -370,9 +370,8 @@ std::shared_ptr<framework::Tensor> Executor<Dtype, P>::Predict( ...@@ -370,9 +370,8 @@ std::shared_ptr<framework::Tensor> Executor<Dtype, P>::Predict(
std::sort(_tprofile.begin(), _tprofile.end(), compf); std::sort(_tprofile.begin(), _tprofile.end(), compf);
_tprofile.push_back(std::make_pair("total", _ptotal)); _tprofile.push_back(std::make_pair("total", _ptotal));
for (auto const &p : _tprofile) { for (auto const &p : _tprofile) {
std::cout << p.first << std::string(16 - p.first.size(), ' ') << "\t" printf("%-16s\t%-10.0f\t%-.4f\n", p.first.c_str(), (float)p.second,
<< p.second << "\t\t" << (float)p.second / _ptotal * 100.0 (float)p.second / _ptotal * 100.0);
<< "\n";
} }
std::cout << "====================[---------]======================\n"; std::cout << "====================[---------]======================\n";
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册