#ifndef QCORE_H #define QCORE_H #include inline QString byteSizeStr(double size) { const char *units[]{"B", "KB", "MB", "GB", "TB", "PB"}; auto i = 0; for(; size >= 1024 && i < 5; i++) size /= 1024; return QString::number(size, 'g', 3)+" "+units[i]; } inline long long steady_milli() { return std::chrono::duration_cast(std::chrono::steady_clock::now().time_since_epoch()).count(); } inline long long system_milli() { return std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); } inline long long steady_micro() { return std::chrono::duration_cast(std::chrono::steady_clock::now().time_since_epoch()).count(); } inline long long system_micro() { return std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); } template inline QThread *ThreadStart(Func &&f) { QThread* thread = QThread::create(f); QObject::connect(thread, &QThread::finished, thread, &QThread::deleteLater); thread->start(); return thread; } #endif