summaryrefslogtreecommitdiffstats
path: root/src/testlib
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2022-10-21 14:31:10 -0700
committerThiago Macieira <thiago.macieira@intel.com>2022-11-09 02:18:45 -0700
commitdbc9467ca327af9f46fd948ea47de2f96db241c9 (patch)
tree228009bc7b83a5bdf5ac900286666e568e71ece1 /src/testlib
parent1fef390ad7ea836b76ed48dfd57e45f9e2f02c19 (diff)
QBenchlib/Perf: use one system call to enable/disable measurements
The man page says the prctl() should apply to any performance counters measuring the current process, so it should work with a perf stat started with --delay=-1... but I couldn't make that work. Change-Id: I3c79b7e08fa346988dfefffd172032f06cc10fa0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/testlib')
-rw-r--r--src/testlib/qbenchmarkperfevents.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/testlib/qbenchmarkperfevents.cpp b/src/testlib/qbenchmarkperfevents.cpp
index 6350c777cd..1b9101e854 100644
--- a/src/testlib/qbenchmarkperfevents.cpp
+++ b/src/testlib/qbenchmarkperfevents.cpp
@@ -17,8 +17,9 @@
#include <string.h>
#include <stdio.h>
-#include <sys/syscall.h>
#include <sys/ioctl.h>
+#include <sys/prctl.h>
+#include <sys/syscall.h>
#include "3rdparty/linux_perf_event_p.h"
@@ -504,15 +505,13 @@ void QBenchmarkPerfEventsMeasurer::start()
// enable the counters
for (int fd : std::as_const(fds))
::ioctl(fd, PERF_EVENT_IOC_RESET);
- for (int fd : std::as_const(fds))
- ::ioctl(fd, PERF_EVENT_IOC_ENABLE);
+ prctl(PR_TASK_PERF_EVENTS_ENABLE);
}
QList<QBenchmarkMeasurerBase::Measurement> QBenchmarkPerfEventsMeasurer::stop()
{
// disable the counters
- for (int fd : std::as_const(fds))
- ::ioctl(fd, PERF_EVENT_IOC_DISABLE);
+ prctl(PR_TASK_PERF_EVENTS_DISABLE);
const QList<PerfEvent> &counters = *eventTypes;
QList<Measurement> result(counters.size(), {});