main.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include <QCoreApplication>
  2. #include <thread>
  3. // #include "Logs/loginit.h"
  4. #include "spdlog/spdlog.h"
  5. #include "FmtLog/fmtlog.h"
  6. void printCPPTime()
  7. {
  8. std::chrono::steady_clock::time_point lastTime = std::chrono::steady_clock::now();
  9. long count = 0;
  10. while(true)
  11. {
  12. std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
  13. // SPDLOG_INFO("C++风格的时间 间隔: {} us", std::chrono::duration_cast<std::chrono::microseconds>(now - lastTime).count());
  14. lastTime = now;
  15. count++;
  16. std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  17. }
  18. }
  19. void printCTime()
  20. {
  21. std::time_t lastTime = std::time(nullptr);
  22. long count = 0;
  23. while(true)
  24. {
  25. std::time_t now = std::time(nullptr);
  26. // SPDLOG_INFO("***** C风格的时间 间隔: {} us", std::difftime(now, lastTime));
  27. lastTime = now;
  28. count++;
  29. std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  30. }
  31. }
  32. int main(int argc, char *argv[])
  33. {
  34. QCoreApplication a(argc, argv);
  35. FMTLOG_INFO("********** Time **********");
  36. // init_log();
  37. SPDLOG_INFO("********** Time **********");
  38. // CPPTP.add_task(printCPPTime);
  39. // CPPTP.add_task(printCTime);
  40. auto now = std::time(nullptr);
  41. // SPDLOG_INFO("{}", std::ctime(&now));
  42. return a.exec();
  43. }