TimerRecord.cpp 907 B

12345678910111213141516171819202122232425262728293031
  1. //
  2. // Created by zx on 22-11-22.
  3. //
  4. #include "TimerRecord.h"
  5. #include <algorithm>
  6. //
  7. // Created by zx on 22-11-3.
  8. //
  9. void TimerRecord::PrintAll()
  10. {
  11. std::cout <<">> ===== Printing run time ====="<<std::endl;
  12. for (const auto& r : records_) {
  13. auto v = std::minmax_element(r.second.timesqueue_.begin(), r.second.timesqueue_.end());
  14. std::cout<< "> [ " << r.first << " ] average time usage: "
  15. << std::accumulate(r.second.timesqueue_.begin(), r.second.timesqueue_.end(), 0.0) /
  16. double(r.second.timesqueue_.size())
  17. << " ms , called times: " << r.second.timesqueue_.size()<<
  18. " max:"<<*v.second<<"ms , min:"<<*v.first<<"ms"<<std::endl;
  19. }
  20. std::cout << ">>> ===== Printing run time end ====="<<std::endl;
  21. }
  22. std::map<std::string,FuncRecord> TimerRecord::records_;//=std::map<std::string,FuncRecord>();
  23. std::mutex TimerRecord::mutex_;