12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 | // Copyright (C) 2016 Intel Corporation.// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only#include"qcsvbenchmarklogger_p.h"#include"qtestresult_p.h"#include"qbenchmark_p.h"#include <cstdio>/*! \internal \class QCsvBenchmarkLogger \inmodule QtTest QCsvBenchmarkLogger implements a comma-separated value format for benchmarks. This is intended to be suitable for import into spreadsheets. It does not print test failures, debug messages, warnings or any other details.*/QCsvBenchmarkLogger::QCsvBenchmarkLogger(const char*filename):QAbstractTestLogger(filename){}QCsvBenchmarkLogger::~QCsvBenchmarkLogger() =default;voidQCsvBenchmarkLogger::startLogging(){// don't print anything}voidQCsvBenchmarkLogger::stopLogging(){// don't print anything}voidQCsvBenchmarkLogger::enterTestFunction(const char*){// don't print anything}voidQCsvBenchmarkLogger::leaveTestFunction(){// don't print anything}voidQCsvBenchmarkLogger::addIncident(QAbstractTestLogger::IncidentTypes,const char*,const char*,int){// don't print anything}voidQCsvBenchmarkLogger::addBenchmarkResult(const QBenchmarkResult &result){const char*fn =QTestResult::currentTestFunction() ?QTestResult::currentTestFunction():"UnknownTestFunc";const char*tag =QTestResult::currentDataTag() ?QTestResult::currentDataTag() :"";const char*gtag =QTestResult::currentGlobalDataTag()?QTestResult::currentGlobalDataTag():"";const char*filler = (tag[0] && gtag[0]) ?":":"";const char*metric =QTest::benchmarkMetricName(result.measurement.metric);char buf[1024];// "function","[globaltag:]tag","metric",value_per_iteration,total,iterationsstd::snprintf(buf,sizeof(buf),"\"%s\",\"%s%s%s\",\"%s\",%.13g,%.13g,%u\n", fn, gtag, filler, tag, metric, result.measurement.value / result.iterations, result.measurement.value, result.iterations);outputString(buf);}voidQCsvBenchmarkLogger::addMessage(QAbstractTestLogger::MessageTypes,const QString &,const char*,int){// don't print anything}
|