| 705 | } |
| 706 | |
| 707 | void testSampleCpu() |
| 708 | { |
| 709 | QStringList perfOptions = {QStringLiteral("--call-graph"), QStringLiteral("dwarf"), |
| 710 | QStringLiteral("--sample-cpu"), QStringLiteral("-e"), QStringLiteral("cycles")}; |
| 711 | if (m_capabilities.canProfileOffCpu) { |
| 712 | perfOptions += PerfRecord::offCpuProfilingOptions(); |
| 713 | } |
| 714 | |
| 715 | const QString exePath = findExe(QStringLiteral("cpp-parallel")); |
| 716 | const int numThreads = QThread::idealThreadCount(); |
| 717 | const QStringList exeArgs = {QString::number(numThreads)}; |
| 718 | |
| 719 | QTemporaryFile tempFile; |
| 720 | tempFile.open(); |
| 721 | |
| 722 | try { |
| 723 | perfRecord(perfOptions, exePath, exeArgs, tempFile.fileName()); |
| 724 | testPerfData({}, {}, tempFile.fileName(), false); |
| 725 | } catch (...) { |
| 726 | } |
| 727 | |
| 728 | QCOMPARE(m_eventData.threads.size(), numThreads + 1); |
| 729 | QCOMPARE(m_eventData.cpus.size(), numThreads); |
| 730 | |
| 731 | if (m_capabilities.canProfileOffCpu) { |
| 732 | QCOMPARE(m_bottomUpData.costs.numTypes(), 3); |
| 733 | QCOMPARE(m_bottomUpData.costs.typeName(0), QStringLiteral("cycles")); |
| 734 | QCOMPARE(m_bottomUpData.costs.typeName(1), QStringLiteral("sched:sched_switch")); |
| 735 | QCOMPARE(m_bottomUpData.costs.typeName(2), QStringLiteral("off-CPU Time")); |
| 736 | |
| 737 | QSet<quint32> eventCpuIds[3]; |
| 738 | for (const auto& thread : std::as_const(m_eventData.threads)) { |
| 739 | for (const auto& event : thread.events) { |
| 740 | eventCpuIds[event.type].insert(event.cpuId); |
| 741 | } |
| 742 | } |
| 743 | QVERIFY(eventCpuIds[0].size() > 1); |
| 744 | QVERIFY(eventCpuIds[1].size() > 1); |
| 745 | QVERIFY(eventCpuIds[2].size() > 1); |
| 746 | } else { |
| 747 | qDebug() << "skipping extended off-CPU profiling check"; |
| 748 | } |
| 749 | } |
| 750 | |
| 751 | void testCustomCostAggregation_data() |
| 752 | { |