forked from linuxdeepin/deepin-compressor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebugTimeManager.cpp
More file actions
75 lines (65 loc) · 2.44 KB
/
DebugTimeManager.cpp
File metadata and controls
75 lines (65 loc) · 2.44 KB
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
// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd.
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "DebugTimeManager.h"
#include <QDateTime>
#include <QDebug>
#include <sys/time.h>
DebugTimeManager *DebugTimeManager::s_Instance = nullptr;
DebugTimeManager::DebugTimeManager()
{
qDebug() << "DebugTimeManager instance created";
}
void DebugTimeManager::clear()
{
qDebug() << "Clearing all debug points";
m_MapPoint.clear();
qDebug() << "Debug points cleared";
}
void DebugTimeManager::beginPointQt(const QString &point, const QString &status)
{
qDebug() << "Begin Qt debug point:" << point << "status:" << status;
PointInfo info;
info.desc = status;
info.time = QDateTime::currentMSecsSinceEpoch();
m_MapPoint.insert(point, info);
qDebug() << "Qt debug point started";
}
void DebugTimeManager::endPointQt(const QString &point)
{
qDebug() << "End Qt debug point:" << point;
if (m_MapPoint.find(point) != m_MapPoint.end()) {
m_MapPoint[point].time = QDateTime::currentMSecsSinceEpoch() - m_MapPoint[point].time;
qInfo() << QString("[GRABPOINT] %1 %2 time=%3ms").arg(point).arg(m_MapPoint[point].desc).arg(m_MapPoint[point].time);
m_MapPoint.remove(point);
qDebug() << "Qt debug point ended successfully";
} else {
qWarning() << "Qt debug point not found:" << point;
}
}
void DebugTimeManager::beginPointLinux(const QString &point, const QString &status)
{
qDebug() << "Begin Linux debug point:" << point << "status:" << status;
struct timeval tv;
gettimeofday(&tv, nullptr);
PointInfo info;
info.desc = status;
info.time = tv.tv_sec * 1000 + tv.tv_usec / 1000;
m_MapPoint.insert(point, info);
qDebug() << "Linux debug point started";
}
void DebugTimeManager::endPointLinux(const QString &point)
{
qDebug() << "End Linux debug point:" << point;
if (m_MapPoint.find(point) != m_MapPoint.end()) {
struct timeval tv;
gettimeofday(&tv, nullptr);
m_MapPoint[point].time = tv.tv_sec * 1000 + tv.tv_usec / 1000 - m_MapPoint[point].time;
qInfo() << QString("[GRABPOINT] %1 %2 time=%3ms").arg(point).arg(m_MapPoint[point].desc).arg(m_MapPoint[point].time);
m_MapPoint.remove(point);
qDebug() << "Linux debug point ended successfully";
} else {
qWarning() << "Linux debug point not found:" << point;
}
}