4#include <QtTest/private/qbenchmark_p.h>
6#include <QtTest/private/qbenchmarkvalgrind_p.h>
7#include <QtCore/qstringlist.h>
8#include <QtCore/qcoreapplication.h>
9#include <QtCore/qprocess.h>
10#include <QtCore/qdir.h>
11#include <QtCore/qregularexpression.h>
12#include <QtCore/qset.h>
13#include <QtTest/private/callgrind_p.h>
29 process.start(u
"valgrind"_s,
QStringList(u
"--version"_s));
30 return process.waitForStarted() && process.waitForFinished(-1);
39 qWarning(
"failed to run callgrind subprocess");
59 std::optional<qint64>
val = std::nullopt;
67 const auto r = std::from_chars(maybeNumber,
end,
v);
68 if (
r.ec == std::errc{}) {
75 qFatal(
"Failed to extract result");
93 for (
const QFileInfo &fileInfo : fiList) {
97 const int suffix =
match.captured(1).toInt(&
ok);
100 if (suffix > hiSuffix) {
101 lastFileInfo = fileInfo;
123 for (
const QFileInfo &fileInfo : fiList) {
141 const QString &execFile = origAppArgs.at(0);
143 u
"--quiet"_s, execFile, u
"-callgrindchild"_s };
147 for (
int i = 1;
i < origAppArgs.size(); ++
i) {
149 if (
arg ==
"-callgrind"_L1)
155 process.start(u
"valgrind"_s,
args);
156 process.waitForStarted(-1);
159 const bool finishedOk = process.waitForFinished(-1);
160 exitCode = process.exitCode();
162 dumpOutput(process.readAllStandardOutput(), stdout);
163 dumpOutput(process.readAllStandardError(), stderr);
170 CALLGRIND_ZERO_STATS;
175 CALLGRIND_DUMP_STATS;
bool needsWarmupIteration() override
int adjustMedianCount(int) override
int adjustIterationCount(int) override
bool isMeasurementAccepted(Measurement measurement) override
QList< Measurement > stop() override
static QBenchmarkGlobalData * current
QString callgrindOutFileBase
static bool runCallgrindSubProcess(const QStringList &origAppArgs, int &exitCode)
static qint64 extractLastResult()
static QString outFileBase(qint64 pid=-1)
static QString getNewestFileName()
static bool rerunThroughCallgrind(const QStringList &origAppArgs, int &exitCode)
static bool haveValgrind()
static qint64 extractResult(const QString &fileName)
static qint64 applicationPid() Q_DECL_CONST_FUNCTION
QFileInfoList entryInfoList(Filters filters=NoFilter, SortFlags sort=NoSort) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool atEnd() const override
Returns true if the end of the file has been reached; otherwise returns false.
\inmodule QtCore \reentrant
QString fileName() const
Returns the name of the file, excluding the path.
bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
bool remove()
Removes the file specified by fileName().
qint64 readLine(char *data, qint64 maxlen)
This function reads a line of ASCII characters from the device, up to a maximum of maxSize - 1 bytes,...
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
bool empty() const noexcept
\inmodule QtCore \reentrant
\inmodule QtCore \reentrant
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
qsizetype size() const
Returns the number of characters in this string.
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QChar * data()
Returns a pointer to the data stored in the QString.
Combined button and popup list for selecting options.
static void dumpOutput(const QByteArray &data, FILE *fh)
AudioChannelLayoutTag tag
GLsizei const GLfloat * v
[13]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
static bool match(const uchar *found, uint foundLen, const char *target, uint targetLen)