summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtestcase.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-04-09 17:16:31 -0300
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-06 21:50:28 +0100
commit051f68c2d3a069543dce4d560facff6aa22284bd (patch)
tree46f02c108b63c88fe871f5f1be9e549dfa2e9e4f /src/testlib/qtestcase.cpp
parent93fe3895cfad75f095b8b1d48cce48ba17600b4e (diff)
Add support for more performance counters in QBenchlib
Added support for most hardware and software counters available on Linux 3.3. The cache-based counters are missing because they need special handling. Also added an option that lists available counters. Note that the list is of counters the library knows about, not the counters that the hardware can measure. Change-Id: I9f6fb09b5460bf4ac6082081611c1d6ff806a3fa Reviewed-by: Jason McDonald <macadder1@gmail.com>
Diffstat (limited to 'src/testlib/qtestcase.cpp')
-rw-r--r--src/testlib/qtestcase.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 87d32da26a..c1ab574291 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -1343,6 +1343,8 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
#endif
#ifdef QTESTLIB_USE_PERF_EVENTS
" -perf : Use Linux perf events to time benchmarks\n"
+ " -perfcounter name : Use the counter named 'name'\n"
+ " -perfcounterlist : Lists the counters available\n"
#endif
#ifdef HAVE_TICK_COUNTER
" -tickcounter : Use CPU tick counters to time benchmarks\n"
@@ -1492,6 +1494,16 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
} else {
fprintf(stderr, "WARNING: Linux perf events not available. Using the walltime measurer.\n");
}
+ } else if (strcmp(argv[i], "-perfcounter") == 0) {
+ if (i + 1 >= argc) {
+ fprintf(stderr, "-perfcounter needs an extra parameter with the name of the counter\n");
+ exit(1);
+ } else {
+ QBenchmarkPerfEventsMeasurer::setCounter(argv[++i]);
+ }
+ } else if (strcmp(argv[i], "-perfcounterlist") == 0) {
+ QBenchmarkPerfEventsMeasurer::listCounters();
+ exit(0);
#endif
#ifdef HAVE_TICK_COUNTER
} else if (strcmp(argv[i], "-tickcounter") == 0) {