#ifndef PERFORMANCELOGGER_H #define PERFORMANCELOGGER_H #include #include #include #include #include #include #include #include #include class PerformanceLogger { public: struct Record { QString category; QString name; qint64 elapsedMs = 0; QDateTime timestamp; }; static PerformanceLogger &instance(); void beginSession(const QString &sessionName = QString()); void endSession(); void log(const QString &category, const QString &name, qint64 elapsedMs); void printReport() const; void saveToFile(const QString &filePath) const; QString reportString() const; QVector records() const; void clear(); private: PerformanceLogger() = default; mutable QMutex m_mutex; QVector m_records; QString m_sessionName; bool m_sessionActive = false; }; class ScopedPerfTimer { public: ScopedPerfTimer(const QString &category, const QString &name); ~ScopedPerfTimer(); private: QString m_category; QString m_name; QElapsedTimer m_timer; }; #define SCOPED_PERF_TIMER(category, name) ScopedPerfTimer _perfTimer(category, name) #endif // PERFORMANCELOGGER_H