Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qcsvbenchmarklogger.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 Intel Corporation.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#
include
"qcsvbenchmarklogger_p.h"
5
#
include
"qtestresult_p.h"
6
#
include
"qbenchmark_p.h"
7
8
#
include
<
cstdio
>
9
10
/*! \internal
11
\class QCsvBenchmarkLogger
12
\inmodule QtTest
13
14
QCsvBenchmarkLogger implements a comma-separated value format for benchmarks.
15
16
This is intended to be suitable for import into spreadsheets.
17
It does not print test failures, debug messages, warnings or any other details.
18
*/
19
20
QCsvBenchmarkLogger
::
QCsvBenchmarkLogger
(
const
char
*filename)
21
:
QAbstractTestLogger
(
filename
)
22
{
23
}
24
25
QCsvBenchmarkLogger
::~
QCsvBenchmarkLogger
() =
default
;
26
27
void
QCsvBenchmarkLogger
::
startLogging
()
28
{
29
// don't print anything
30
}
31
32
void
QCsvBenchmarkLogger
::
stopLogging
()
33
{
34
// don't print anything
35
}
36
37
void
QCsvBenchmarkLogger
::
enterTestFunction
(
const
char
*)
38
{
39
// don't print anything
40
}
41
42
void
QCsvBenchmarkLogger
::
leaveTestFunction
()
43
{
44
// don't print anything
45
}
46
47
void
QCsvBenchmarkLogger
::
addIncident
(
QAbstractTestLogger
::
IncidentTypes
,
const
char
*,
const
char
*,
int
)
48
{
49
// don't print anything
50
}
51
52
void
QCsvBenchmarkLogger
::
addBenchmarkResult
(
const
QBenchmarkResult
&result)
53
{
54
const
char
*fn = QTestResult::currentTestFunction() ? QTestResult::currentTestFunction()
55
:
"UnknownTestFunc"
;
56
const
char
*tag = QTestResult::currentDataTag() ? QTestResult::currentDataTag() :
""
;
57
const
char
*gtag = QTestResult::currentGlobalDataTag()
58
? QTestResult::currentGlobalDataTag()
59
:
""
;
60
const
char
*filler = (tag[0] && gtag[0]) ?
":"
:
""
;
61
62
const
char
*metric = QTest::benchmarkMetricName(result.measurement.metric);
63
64
char
buf[1024];
65
// "function","[globaltag:]tag","metric",value_per_iteration,total,iterations
66
std
::snprintf(buf,
sizeof
(buf),
"\"%s\",\"%s%s%s\",\"%s\",%.13g,%.13g,%.13g,%u\n"
,
67
fn, gtag, filler, tag, metric,
68
result.measurement.value / result
.
iterations
,
69
result.measurement.value, sqrt(result.measurement.variance),
70
result
.
iterations
);
71
outputString
(
buf
)
;
72
}
73
74
void
QCsvBenchmarkLogger
::addMessage(QAbstractTestLogger::MessageTypes,
const
QString &,
const
char
*,
int
)
75
{
76
// don't print anything
77
}
QAbstractTestLogger::outputString
void outputString(const char *msg)
Convenience method to write msg to the output stream.
Definition
qabstracttestlogger.cpp:204
QBenchmarkResult
Definition
qbenchmark_p.h:61
QBenchmarkResult::iterations
int iterations
Definition
qbenchmark_p.h:65
QCsvBenchmarkLogger
Definition
qcsvbenchmarklogger_p.h:23
QCsvBenchmarkLogger::QCsvBenchmarkLogger
QCsvBenchmarkLogger(const char *filename)
Definition
qcsvbenchmarklogger.cpp:20
QCsvBenchmarkLogger::addIncident
void addIncident(IncidentTypes type, const char *description, const char *file=nullptr, int line=0) override
This virtual method is called when an event occurs that relates to the resolution of the test.
Definition
qcsvbenchmarklogger.cpp:47
QCsvBenchmarkLogger::enterTestFunction
void enterTestFunction(const char *function) override
This virtual method is called before each test function is invoked.
Definition
qcsvbenchmarklogger.cpp:37
QCsvBenchmarkLogger::addBenchmarkResult
void addBenchmarkResult(const QBenchmarkResult &result) override
This virtual method is called after a benchmark has been run enough times to produce usable data.
Definition
qcsvbenchmarklogger.cpp:52
QCsvBenchmarkLogger::stopLogging
void stopLogging() override
Called after the end of a test run.
Definition
qcsvbenchmarklogger.cpp:32
QCsvBenchmarkLogger::leaveTestFunction
void leaveTestFunction() override
This virtual method is called after a test function has completed, to match \l enterTestFunction().
Definition
qcsvbenchmarklogger.cpp:42
QCsvBenchmarkLogger::startLogging
void startLogging() override
Called before the start of a test run.
Definition
qcsvbenchmarklogger.cpp:27
QCsvBenchmarkLogger::~QCsvBenchmarkLogger
~QCsvBenchmarkLogger()
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
qtbase
src
testlib
qcsvbenchmarklogger.cpp
Generated on
for Qt by
1.18.0