RUPerfTimer.h 813 B

123456789101112131415161718192021222324252627282930313233343536
  1. //
  2. // 资源加载类
  3. //
  4. #ifndef RUPerfTimer_h
  5. #define RUPerfTimer_h
  6. #include "cocos2d.h"
  7. #include "RUDefine.h"
  8. NS_RU_BEGIN
  9. #define gPerfTimer(key) redutils::PerfTimer::instance(key)
  10. class PerfTimer : public Ref {
  11. public:
  12. static PerfTimer* instance(std::string key4Loader);
  13. void start();
  14. void stop();
  15. void clear();
  16. void dump(int indent = 0);
  17. private:
  18. PerfTimer() = default;
  19. ~PerfTimer() = default;
  20. private:
  21. static std::unordered_map<std::string, PerfTimer*> _gPerfTimers;
  22. std::string _perfTimerName; //仅起log输出用
  23. std::chrono::steady_clock::time_point _startTime;
  24. std::chrono::steady_clock::time_point _endTime;
  25. std::chrono::steady_clock::duration _duration = std::chrono::steady_clock::duration::zero();
  26. };
  27. NS_RU_END
  28. #endif /* RUPerfTimer_h */