MCPcopy Create free account
hub / github.com/Tencent/loli_profiler / LoadFromFile

Method LoadFromFile

src/profilecomparator.cpp:56–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56bool ProfileComparator::LoadFromFile(const QString& filePath, ProfileData& data)
57{
58 QFile file(filePath);
59 if (!file.open(QIODevice::ReadOnly)) {
60 errorMessage_ = QString("Cannot open file: %1").arg(filePath);
61 return false;
62 }
63
64 QDataStream stream(&file);
65 stream.setVersion(QDataStream::Qt_5_12);
66
67 // Read magic and version
68 quint32 magic;
69 qint32 version;
70 stream >> magic;
71 if (magic != APP_MAGIC) {
72 errorMessage_ = QString("Invalid magic number in file: %1").arg(filePath);
73 return false;
74 }
75
76 stream >> version;
77 if (version != APP_VERSION) {
78 errorMessage_ = QString("Version mismatch in file: %1 (expected %2, got %3)")
79 .arg(filePath).arg(APP_VERSION).arg(version);
80 return false;
81 }
82
83 // Read meminfo charts
84 stream >> data.maxMemInfoValue;
85 qint32 seriesCount;
86 stream >> seriesCount;
87 data.memInfoSeries.resize(seriesCount);
88 for (int i = 0; i < seriesCount; i++) {
89 qint32 pointsCount;
90 stream >> pointsCount;
91 QVector<QPair<int, int>>& points = data.memInfoSeries[i].second;
92 points.reserve(pointsCount);
93 for (int j = 0; j < pointsCount; j++) {
94 QPointF point;
95 stream >> point;
96 points.append(qMakePair(static_cast<int>(point.x()), static_cast<int>(point.y())));
97 }
98 }
99
100 // Read string hashes
101 data.stringHashMap.clear();
102 stream >> data.stringHashMap;
103
104 // Update global HashString map (needed for HashString::Get() to work)
105 for (auto it = data.stringHashMap.begin(); it != data.stringHashMap.end(); ++it) {
106 HashString::hashmap_[it.key()] = it.value();
107 }
108
109 // Read stack trace records
110 qint32 recordCount;
111 stream >> recordCount;
112 data.stackRecords.clear();
113 data.stackRecords.reserve(recordCount);

Callers

nothing calls this directly

Calls 3

SMapsSectionAddrClass · 0.85
appendMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected