| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- //
- // Created by zx on 22-11-3.
- //
- #ifndef SRC_LIO_LIVOX_SRC_UTILS_TIMERECORD_H_
- #define SRC_LIO_LIVOX_SRC_UTILS_TIMERECORD_H_
- #include <chrono>
- #include <fstream>
- #include <map>
- #include <numeric>
- #include <string>
- #include <vector>
- class TimeRecord
- {
- public:
- struct Record {
- Record() = default;
- Record(const std::string& name, double time_usage) {
- func_name_ = name;
- time_usage_in_ms_.emplace_back(time_usage);
- }
- std::string func_name_;
- std::vector<double> time_usage_in_ms_;
- };
- template <class F>
- static void Evaluate(F&& func, const std::string& func_name);
- static void PrintAll();
- static void DumpIntoFile(const std::string& file_name);
- static double GetMeanTime(const std::string& func_name);
- private:
- static std::map<std::string, Record> records_;
- };
- #endif //SRC_LIO_LIVOX_SRC_UTILS_TIMERECORD_H_
|