Skip to content

Commit

Permalink
skip zero cost entries
Browse files Browse the repository at this point in the history
fixes #578
  • Loading branch information
GitMensch committed Dec 21, 2023
1 parent a8d1440 commit 802d166
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/parsers/perf/perfparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1053,11 +1053,20 @@ class PerfParserPrivate : public QObject

auto& core = frequencyResult.cores[sample.cpu];
for (const auto& cost : sample.costs) {

if (cost.attributeId < 0) {
// CHECKME: where does that happen (see testcase), is this an issue with
// perfparser and how should this be handled here
qCWarning(LOG_PERFPARSER) << "Unexpected attribute id:" << cost.attributeId;
continue;
}

if (core.costs.size() <= cost.attributeId) {
const auto oldSize = core.costs.size();
core.costs.resize(cost.attributeId + 1);
const auto newSize = cost.attributeId + 1;
core.costs.resize(newSize);

for (int i = oldSize; i < core.costs.size(); i++) {
for (int i = oldSize; i < newSize; i++) {
core.costs[i].costName = strings.at(attributes[i].name.id);
}
}
Expand Down
Binary file added tests/integrationtests/perf.data.ZeroCost
Binary file not shown.
14 changes: 14 additions & 0 deletions tests/integrationtests/tst_perfparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,20 @@ private slots:
}
}

void testZeroCost()
{

PerfParser parser(this);
QSignalSpy parsingFailedSpy(&parser, &PerfParser::parsingFailed);
QSignalSpy parsingFinishedSpy(&parser, &PerfParser::parsingFinished);

parser.startParseFile(QFINDTESTDATA("perf.data.ZeroCost"));

// CHECKME: hotspot-perfparser alone needs 35 seconds to parse this file
QTRY_COMPARE_WITH_TIMEOUT(parsingFinishedSpy.count(), 1, 45000);
QCOMPARE(parsingFailedSpy.count(), 0);
}

void testCppInliningNoOptions()
{
const QStringList perfOptions;
Expand Down

0 comments on commit 802d166

Please sign in to comment.