1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #include <QCoreApplication>
- #include <thread>
- // #include "Logs/loginit.h"
- #include "spdlog/spdlog.h"
- #include "FmtLog/fmtlog.h"
- void printCPPTime()
- {
- std::chrono::steady_clock::time_point lastTime = std::chrono::steady_clock::now();
- long count = 0;
- while(true)
- {
- std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
- // SPDLOG_INFO("C++风格的时间 间隔: {} us", std::chrono::duration_cast<std::chrono::microseconds>(now - lastTime).count());
- lastTime = now;
- count++;
- std::this_thread::sleep_for(std::chrono::milliseconds(1000));
- }
- }
- void printCTime()
- {
- std::time_t lastTime = std::time(nullptr);
- long count = 0;
- while(true)
- {
- std::time_t now = std::time(nullptr);
- // SPDLOG_INFO("***** C风格的时间 间隔: {} us", std::difftime(now, lastTime));
- lastTime = now;
- count++;
- std::this_thread::sleep_for(std::chrono::milliseconds(1000));
- }
- }
- int main(int argc, char *argv[])
- {
- QCoreApplication a(argc, argv);
- FMTLOG_INFO("********** Time **********");
- // init_log();
- SPDLOG_INFO("********** Time **********");
- // CPPTP.add_task(printCPPTime);
- // CPPTP.add_task(printCTime);
- auto now = std::time(nullptr);
- // SPDLOG_INFO("{}", std::ctime(&now));
- return a.exec();
- }
|