1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
/*
* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd.
*
* Author: zyc <zyc@uniontech.com>
*
* Maintainer: zyc <zyc@uniontech.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DEBUGTIMEMANAGER_H
#define DEBUGTIMEMANAGER_H
#include <QObject>
#include <QMap>
#include <QString>
#include "config.h"
#define PERF_ON
#ifdef PERF_ON
#define PERF_PRINT_BEGIN(point, dsec) DebugTimeManager::getInstance()->beginPointLinux(point,dsec)
#define PERF_PRINT_END(point, dsec) DebugTimeManager::getInstance()->endPointLinux(point, dsec)
#else
#define PERF_PRINT_BEGIN(point, dsec)
#define PERF_PRINT_END(point, dsec)
#endif
/**
* @brief The PointInfo struct
*/
struct PointInfo {
QString desc;
qint64 time;
};
struct PointInfoLinux {
QString desc;
timespec time;
};
class DebugTimeManager
{
public:
/**
* @brief getInstance : get signal instance
* @return : the signal instance
*/
static DebugTimeManager *getInstance()
{
static DebugTimeManager m_manager;
return &m_manager;
}
/**
* @brief clear : clear data
*/
void clear();
/**
* @brief beginPointQt : 打点开始,Qt
* @param point : 所打的点的名称,固定格式,在打点文档中查看 -- POINT-XX POINT-01
* @param status : 性能测试的状态,比如测试时文件的大小
*/
// void beginPointQt(const QString &point, const QString &status = "");
/**
* @brief endPointQt : 结束打点,Qt
* @param point : 需要结束的点
*/
// void endPointQt(const QString &point);
/**
* @brief beginPointLinux : 打点开始,Linux
* @param point : 所打的点的名称,固定格式,在打点文档中查看 -- POINT-XX POINT-01
* @param status : 性能测试的状态,比如测试时文件的大小
*/
void beginPointLinux(const QString &point, const QString &status = "");
/**
* @brief endPointLinux : 结束打点,Linux
* @param point : 需要结束的点
*/
void endPointLinux(const QString &point, const QString &status = "");
/**
* @brief diff 计算两个timespec结构体时间之差
* @param start 开始时间
* @param end 结束时间
* @return 时间差
*/
timespec diff(timespec start, timespec end);
protected:
DebugTimeManager();
private:
QMap<QString, PointInfo> m_MapPoint; //<! 保存所打的点
QMap<QString, PointInfoLinux> m_MapLinuxPoint; //<! 保存所打的点
};
#endif // DEBUGTIMEMANAGER_H
|