//
// Created by zx on 22-11-22.
//

#include "TimerRecord.h"
#include <algorithm>
//
// Created by zx on 22-11-3.
//


void TimerRecord::PrintAll()
{
  std::cout <<">> ===== Printing run time ====="<<std::endl;
  for (const auto& r : records_) {
    auto v = std::minmax_element(r.second.timesqueue_.begin(), r.second.timesqueue_.end());

    std::cout<< "> [ " << r.first << " ] average time usage: "
             << std::accumulate(r.second.timesqueue_.begin(), r.second.timesqueue_.end(), 0.0) /
                     double(r.second.timesqueue_.size())
             << " ms , called times: " << r.second.timesqueue_.size()<<
             "   max:"<<*v.second<<"ms , min:"<<*v.first<<"ms"<<std::endl;
  }
  std::cout << ">>> ===== Printing run time end ====="<<std::endl;
}

std::map<std::string,FuncRecord> TimerRecord::records_;//=std::map<std::string,FuncRecord>();
std::mutex TimerRecord::mutex_;



