Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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
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
24
26
28{
29 // don't print anything
30}
31
33{
34 // don't print anything
35}
36
38{
39 // don't print anything
40}
41
43{
44 // don't print anything
45}
46
47void QCsvBenchmarkLogger::addIncident(QAbstractTestLogger::IncidentTypes, const char *, const char *, int)
48{
49 // don't print anything
50}
51
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,%u\n",
67 fn, gtag, filler, tag, metric,
68 result.measurement.value / result.iterations,
69 result.measurement.value, result.iterations);
71}
72
73void QCsvBenchmarkLogger::addMessage(QAbstractTestLogger::MessageTypes, const QString &, const char *, int)
74{
75 // don't print anything
76}
void outputString(const char *msg)
Convenience method to write msg to the output stream.
QCsvBenchmarkLogger(const char *filename)
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.
void enterTestFunction(const char *function) override
This virtual method is called before each test function is invoked.
void addBenchmarkResult(const QBenchmarkResult &result) override
This virtual method is called after a benchmark has been run enough times to produce usable data.
void stopLogging() override
Called after the end of a test run.
void leaveTestFunction() override
This virtual method is called after a test function has completed, to match \l enterTestFunction().
void startLogging() override
Called before the start of a test run.