main.cpp 727 B

123456789101112131415161718192021222324252627282930313233
  1. #include "widget.h"
  2. #include <QApplication>
  3. #include "Logs/loginit.h"
  4. #include "spdlog/spdlog.h"
  5. #include "Timer/TWTimer.hpp"
  6. std::chrono::steady_clock::time_point lastTime = std::chrono::steady_clock::now();
  7. long count = 0;
  8. void print()
  9. {
  10. std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
  11. SPDLOG_INFO("count:{} 间隔: {} us",count, std::chrono::duration_cast<std::chrono::microseconds>(now - lastTime).count());
  12. lastTime = now;
  13. count++;
  14. }
  15. int main(int argc, char *argv[])
  16. {
  17. QApplication a(argc, argv);
  18. init_log();
  19. SPDLOG_INFO("********** Timer **********");
  20. TimerWheel timer;
  21. timer.Start();
  22. timer.AddTask(1000, print, true);
  23. return a.exec();
  24. }