summaryrefslogtreecommitdiffstats
path: root/src/testlib/qbenchmarkperfevents.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix some narrowing conversion warningsAhmad Samir2023-04-081-1/+2
| | | | | | | | | ioctl call for FIONREAD takes an int arg, it won't work correctly otherwise. Cast the return of the read() call to int, because it won't read more than buffSize (which is an int). Change-Id: I130202a732684257bbb0e79c9358b60a61010c46 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QBenchlib/Perf: use one system call to enable/disable measurementsThiago Macieira2022-11-091-5/+4
| | | | | | | | | 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>
* QBenchlib/Perf: use C++11 range-fors for the event listThiago Macieira2022-11-091-15/+12
| | | | | | | This code predated C++11 and thus had a sentinel element. Change-Id: I3c79b7e08fa346988dfefffd17202ef3f9735683 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QBenchlib/Perf: parse multiple counters from -perfcounterThiago Macieira2022-11-091-13/+24
| | | | | Change-Id: I3c79b7e08fa346988dfefffd17202ec98947308e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QBenchlib: add support for a measurer reporting multiple resultsThiago Macieira2022-11-091-30/+63
| | | | | | | | | | | | | | | | | Implemented for the Linux Perf measurer, with four measurements by default. RESULT : tst_MyClass::QString_toInt(): 149.574444 CPU cycles per iteration (total: 149,574,445, iterations: 1000000) RESULT : tst_MyClass::QString_toInt(): 620.000181 instructions per iteration (total: 620,000,182, iterations: 1000000) RESULT : tst_MyClass::QString_toInt(): 131.000046 branch instructions per iteration (total: 131,000,047, iterations: 1000000) RESULT : tst_MyClass::QString_toInt(): 32.118771 nsecs per iteration (total: 32,118,771, iterations: 1000000) Change-Id: I3c79b7e08fa346988dfefffd17202cda3df8431b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QBenchlib: pass the metric type alongside the measurement valueThiago Macieira2022-11-091-9/+4
| | | | | | | | | | | | | | And pass the value in a qreal, which is what QBenchlib stores anyway. This increases the code size a little because the conversion from integer to qreal is in multiple places, but doesn't meaningfully increase the overhead: in the SysV ABI, we still return Measurement in registers and even using the floating point registers where applicable. This is the first step in allowing the Perf benchmarker to benchmark more than one event. Change-Id: I3c79b7e08fa346988dfefffd172027a8677f17c0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QBenchlib/Perf: remove the handling of attributes in -perfcounterThiago Macieira2022-10-251-31/+4
| | | | | | | | | | | | | I don't think I understood what this does when I coded it. It wasn't needed with the Linux kernels of the era. [ChangeLog][QtTest] Specifying attributes with the -perfcounter command- line option for Linux performance counters is deprecated. QtTest will ignore the colon and any attributes listed there, though future versions of QtTest may reintroduce attributes if needed. Change-Id: I3c79b7e08fa346988dfefffd17202684fc2cf650 Reviewed-by: David Faure <david.faure@kdab.com>
* QBenchlib/Perf: don't try to benchmark the kernelThiago Macieira2022-10-251-5/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The kernel has become more paranoid since 2013, when I originally wrote this code. The kernel.perf_event_paranoid sysctl controls the paranoia level[1]: === ================================================================== -1 Allow use of (almost) all events by all users. Ignore mlock limit after perf_event_mlock_kb without ``CAP_IPC_LOCK``. >=0 Disallow ftrace function tracepoint by users without ``CAP_PERFMON``. Disallow raw tracepoint access by users without ``CAP_PERFMON``. >=1 Disallow CPU event access by users without ``CAP_PERFMON``. >=2 Disallow kernel profiling by users without ``CAP_PERFMON``. === ================================================================== Since the default is 2, we QBenchlib has been failing with EACCESS: PASS : tst_MyClass::initTestCase() QBenchmarkPerfEventsMeasurer::start: perf_event_open: Permission denied [ChangeLog][QtTest] Fixed support of Linux performance counters for QBENCHMARK, which used to fail with "Permission denied" errors in default configurations. Now, QtTest will automatically fall back to profiling only userspace, like the perf(1) tool does. [1] https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/sysctl/kernel.rst#perf-event-paranoid Pick-to: 5.15 6.2 6.4 Change-Id: I3c79b7e08fa346988dfefffd171f897be7794935 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: David Faure <david.faure@kdab.com>
* QBenchlib: remove unused checkpoint() virtualThiago Macieira2022-10-241-8/+0
| | | | | | | | | | | It was probably part of the original design to have an intermediate measurement to determine whether the results were acceptable or not, but it was never used. So just remove. Change-Id: I3c79b7e08fa346988dfefffd1720281b2512b8c1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Jason McDonald <macadder1@gmail.com>
* QBenchlib/Perf: remove ioctl(FD_CLOEXEC)Thiago Macieira2022-10-241-2/+0
| | | | | | | | | Commit 8995045c62bb673af1e74bce79e3c500e0217bae forgot to remove this portion. Pick-to: 6.4 Change-Id: I3c79b7e08fa346988dfefffd17202b19665ddc8a Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QBenchlib/Perf: use WalltimeNanoseconds for the task timeThiago Macieira2022-10-241-8/+4
| | | | | | | | | | | | | | | | | Avoids the special case in the code and removes the need to run a large number of iterations to get any useful result, plus makes it's more readable: From: 0.00002125 msecs per iteration (total: 2,125, iterations: 100000000) To: 22.082 nsecs per iteration (total: 22,082, iterations: 1000) Pick-to: 6.4 Change-Id: I3c79b7e08fa346988dfefffd171facc98af9e9fc Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QBenchlib/Perf: open the perffd with PERF_FLAG_FD_CLOEXECThiago Macieira2022-10-201-2/+1
| | | | | | | | | | | | | This flag was introduced in the Linux kernel version 3.14. Trying to use perf_event_open() now with a kernel older than that will cause EINVAL errors, but 3.14 is from 2014, so most likely old enough for all of Qt 6. For that, I updated the copied header from v6.0. Pick-to: 6.4 Change-Id: I3c79b7e08fa346988dfefffd171f895201ceb4f4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QTestLib: Introduce nullptrFriedemann Kleint2019-07-111-1/+1
| | | | | | | | Apply Fixits by Qt Creator with some amendments. Task-number: QTBUG-69413 Change-Id: I620e40a277dc2b20b0ec26fc32577e66b0456bb3 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* QTestLib: Use member initializationFriedemann Kleint2019-07-111-4/+1
| | | | | | | | Apply Fixits by Qt Creator with some amendments. Task-number: QTBUG-69413 Change-Id: Iba0834dc89cbfc215acc5873f31fa6eeed74177d Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* doc: Fix remaining clang parsing errors in QtTestMartin Smith2018-01-181-1/+3
| | | | | | | | This update also corrects all the remaining qdoc warnings in the mnodule. Change-Id: I1cea2cb1dd515d075a1e49a52ca78fc407c3a324 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Enable support for ref-cycles perf counter in QtTestLib.Milian Wolff2016-03-031-3/+6
| | | | | | | | | | | | 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>
* Updated license headersJani Heikkinen2016-01-211-1/+1
| | | | | | | | | | | | | From Qt 5.7 -> tools & applications are lisenced under GPL v3 with some exceptions, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new GPL-EXCEPT header instead of LGPL21 one (in those files which will be under GPL 3 with exceptions) Change-Id: I42a473ddc97101492a60b9287d90979d9eb35ae1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Updated license headersJani Heikkinen2016-01-151-13/+19
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-111-6/+6
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-18/+10
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Fix file descriptor leak in the perf event counterThiago Macieira2014-01-101-9/+11
| | | | | | | | | | | We opened the counter at every start(), even if we had already started before. Some of the benchlib's options caused it to start() and stop() over and over again, like -minimumvalue and -minimumtotal, which could leak to fd exhaustion (EMFILE). Change-Id: Ifeb7cca65c758877be600dc22928bea74f499934 Reviewed-by: Robin Burchell <robin+qt@viroteck.net> Reviewed-by: Jason McDonald <macadder1@gmail.com>
* Fix compilation of QtTest on Linux systems with old kernel headersThiago Macieira2013-07-211-0/+10
| | | | | | | | | | | | Hardcode our perf_event_open(2) function to simply return -1 and set errno to ENOSYS. This will disable the functionality. People compiling Qt with such old headers will probably carry quite a bit of dead code in QtTest. They should upgrade. Task-number: QTBUG-32507 Change-Id: I774b4a81bee5c3e2ddc75fa52520d123a6bebed9 Reviewed-by: Jason McDonald <macadder1@gmail.com>
* Add support for attributes in the -perfcounter argumentThiago Macieira2013-03-061-1/+38
| | | | | | | | | Five attributes are supported, matching what the perf(1) tool supports. The 'p' attribute (precise IP reporting) wasn't added because we don't do assembly-level debugging with benchlib. Change-Id: I726f735a5bcc0c97e62cde0fbe0843597068ad7c Reviewed-by: Jason McDonald <macadder1@gmail.com>
* Store the performance counter attributes globallyThiago Macieira2013-03-061-22/+27
| | | | | | | This will allow us to modify more attributes from the command-line Change-Id: I84d4933cbfa2b69c4e1009eaf3e005cfc3e7e01c Reviewed-by: Jason McDonald <macadder1@gmail.com>
* Add support for the cache-related operations counters in benchlibThiago Macieira2013-03-061-23/+180
| | | | | | | | | | | | This adds support for checking cache accesses and misses, per operation (read, write and prefetch) as well as per cache level (L1 for data, L1 for instructions, last level). The branch prediction unit (BPU) is also accessed via the cache monitor subsystem. Change-Id: I8fa96b141cc777c9d231bd57fa36bca33ae7bdfd Reviewed-by: Jason McDonald <macadder1@gmail.com>
* Add support for more performance counters in QBenchlibThiago Macieira2013-03-061-8/+198
| | | | | | | | | | | | | 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>
* Add more events for QBenchlib, based on the Linux perf countersThiago Macieira2013-03-061-1/+1
| | | | | Change-Id: Ic7e7e122bfe3995eb7ea033c744fd501579ea8fa Reviewed-by: Jason McDonald <macadder1@gmail.com>
* Implement the Linux Perf Counter backend for benchlibThiago Macieira2013-03-061-1/+104
| | | | | | | | | | | | | | | | Currently, we only support one event type: counting CPU cycles with hardware counters. There are no fallbacks if this hardware counter is not available, and there is currently no way to specify other counters. Benchlib only supports reporting one event per benchmark, even though the event counter interface allows specifying more than one. Still, the hardware usually has limitations on how many events it can monitor at a time, and we'd prefer to have the counter running at 100% of the time, so this will not change. Change-Id: I79858a3ad1e696dc4b7b72c420e5a04b67cd55de Reviewed-by: Jason McDonald <macadder1@gmail.com>
* Add the skeleton Linux perf events counter for QtTestThiago Macieira2013-03-061-0/+115
Currently, it only prints "perf available" if you use the -perf option and perf is available. The implementation comes in the next commits. Change-Id: Ic6cdee70e21df25780799a4bc31ca2c2d923b9f8 Reviewed-by: Jason McDonald <macadder1@gmail.com>