Enable support for ref-cycles perf counter in QtTestLib.

The ref-cycles counter corresponds to the monotonic timestamp counter
that can be read using the RDTSC assembler instruction. Using it
instead of the default cycles counter is useful as it removes the
effect of dynamic frequency scaling on the measurement.

[ChangeLog][QtTest] The ref-cycles perf counter can now be used.

Change-Id: Id7d56576db362706c20f9a399e5acea35ee799f2
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
Milian Wolff 2016-02-16 15:57:15 +01:00
parent 9c1d3bc253
commit fe04aba46d
3 changed files with 13 additions and 4 deletions

View File

@ -56,6 +56,7 @@
\value CPUTicks CPU time
\value CPUMigrations Process migrations between CPUs
\value CPUCycles CPU cycles
\value RefCPUCycles Reference CPU cycles
\value BusCycles Bus cycles
\value StalledCycles Cycles stalled
\value InstructionReads Instruction reads
@ -108,6 +109,8 @@ const char * QTest::benchmarkMetricName(QBenchmarkMetric metric)
return "CPUMigrations";
case CPUCycles:
return "CPUCycles";
case RefCPUCycles:
return "RefCPUCycles";
case BusCycles:
return "BusCycles";
case StalledCycles:
@ -180,6 +183,8 @@ const char * QTest::benchmarkMetricUnit(QBenchmarkMetric metric)
return "CPU migrations";
case CPUCycles:
return "CPU cycles";
case RefCPUCycles:
return "Reference CPU cycles";
case BusCycles:
return "bus cycles";
case StalledCycles:

View File

@ -78,7 +78,8 @@ enum QBenchmarkMetric {
MinorPageFaults,
MajorPageFaults,
AlignmentFaults,
EmulationFaults
EmulationFaults,
RefCPUCycles,
};
}

View File

@ -153,6 +153,7 @@ bool QBenchmarkPerfEventsMeasurer::isAvailable()
Event type Event counter Unit Name and aliases
HARDWARE CPU_CYCLES CPUCycles cycles cpu-cycles
HARDWARE REF_CPU_CYCLES RefCPUCycles ref-cycles
HARDWARE INSTRUCTIONS Instructions instructions
HARDWARE CACHE_REFERENCES CacheReferences cache-references
HARDWARE CACHE_MISSES CacheMisses cache-misses
@ -321,6 +322,7 @@ static const char eventlist_strings[] =
"migrations\0"
"minor-faults\0"
"page-faults\0"
"ref-cycles\0"
"stalled-cycles-backend\0"
"stalled-cycles-frontend\0"
"task-clock\0"
@ -407,9 +409,10 @@ static const Events eventlist[] = {
{ 1256, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_MIGRATIONS, QTest::CPUMigrations },
{ 1267, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MIN, QTest::MinorPageFaults },
{ 1280, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS, QTest::PageFaults },
{ 1292, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_BACKEND, QTest::StalledCycles },
{ 1315, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND, QTest::StalledCycles },
{ 1339, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_TASK_CLOCK, QTest::WalltimeMilliseconds },
{ 1292, PERF_TYPE_HARDWARE, PERF_COUNT_HW_REF_CPU_CYCLES, QTest::RefCPUCycles },
{ 1303, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_BACKEND, QTest::StalledCycles },
{ 1326, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND, QTest::StalledCycles },
{ 1350, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_TASK_CLOCK, QTest::WalltimeMilliseconds },
{ 0, PERF_TYPE_MAX, 0, QTest::Events }
};
/* -- END GENERATED CODE -- */