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");
49 qFatal(
"Could not open filehandle for dumping output: %s",
62 std::optional<qint64> val = std::nullopt;
70 const auto r = std::from_chars(maybeNumber,
end,
v);
71 if (
r.ec == std::errc{}) {
78 qFatal(
"Failed to extract result");
96 for (
const QFileInfo &fileInfo : fiList) {
100 const int suffix =
match.captured(1).toInt(&
ok);
103 if (suffix > hiSuffix) {
104 lastFileInfo = fileInfo;
109 return lastFileInfo.fileName();
126 for (
const QFileInfo &fileInfo : fiList) {
144 const QString &execFile = origAppArgs.
at(0);
146 u
"--quiet"_s, execFile, u
"-callgrindchild"_s };
150 for (
int i = 1;
i < origAppArgs.size(); ++
i) {
152 if (
arg ==
"-callgrind"_L1)
158 process.start(u
"valgrind"_s,
args);
159 process.waitForStarted(-1);
162 const bool finishedOk = process.waitForFinished(-1);
163 exitCode = process.exitCode();
165 dumpOutput(process.readAllStandardOutput(), stdout);
166 dumpOutput(process.readAllStandardError(), stderr);
173 CALLGRIND_ZERO_STATS;
178 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
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.
QFILE_MAYBE_NODISCARD 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.
QString errorString() const
Returns a human-readable description of the last device error that occurred.
\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 noexcept
Returns the number of characters in this string.
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
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)
QList< QString > QStringList
Constructs a string list that contains the given string, str.
AudioChannelLayoutTag tag
GLsizei const GLfloat * v
[13]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
#define qPrintable(string)
static bool match(const uchar *found, uint foundLen, const char *target, uint targetLen)