当前位置: 首页>>代码示例>>C++>>正文


C++ Benchmark::benchmarkStr方法代码示例

本文整理汇总了C++中Benchmark::benchmarkStr方法的典型用法代码示例。如果您正苦于以下问题:C++ Benchmark::benchmarkStr方法的具体用法?C++ Benchmark::benchmarkStr怎么用?C++ Benchmark::benchmarkStr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Benchmark的用法示例。


在下文中一共展示了Benchmark::benchmarkStr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: writeEntriesToFile

void ResultLogger::writeEntriesToFile(const QString &filename, ResultFormat format)
{
    if(m_testFunctions.count() == 0)
        return;

    QTextStream *out = 0;
    QFile file;

    if (filename.length() > 0) {
        file.setFileName(filename);
        if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
            qWarning() << "Opening result file failed: " << filename;
            return;
        }

        out = new QTextStream(&file);
    }
    else {
        out = new QTextStream(stdout);
    }

    if (format == Xml) {
        *out << "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
        *out << "<TestCase name=\"GraphicsViewBenchmark\">\n";
        *out << QString("<Environment><QtVersion>%1</QtVersion><QTestVersion>%2</QTestVersion></Environment>\n").arg(QT_VERSION_STR).arg(QT_VERSION_STR).toAscii();
    }
    if (format == Xml || format == LightXml) {
        for (int i = 0; i <m_testFunctions.count(); ++i) {
            TestFunctionResult *tf = m_testFunctions.at(i);

            *out << QString("<TestFunction name=\"%1\">\n").arg(tf->name());

            Benchmarks* benchmarks = tf->benchmarks();

            if (tf->errors().length() == 0 &&
                    (benchmarks && benchmarks->count() <= 0)) {
                *out << "<Incident type=\"pass\" file=\"\" line=\"0\"/>\n";
            }
            else if (tf->errors().length() > 0) {
                *out << "<Incident type=\"fail\" file=\"\" line=\"0\">\n";
                *out << "<DataTag><![CDATA[ message ]]></DataTag>\n";
                *out << "<Description><![CDATA[";
                QStringList &errors = tf->errors();
                for (int e = 0; e < errors.length(); ++e)
                    *out << errors.at(e) << " ";
                *out << "]]></Description>\n";
                *out << "</Incident>\n";
            }

            for (int j = 0; j < benchmarks->count(); ++j) {
                Benchmark *bm = benchmarks->at(j);
                *out << QString("<BenchmarkResult metric=\"walltime\" tag=\"%1\" value=\"%2\" iterations=\"1\"/>\n").arg(bm->benchmarkStr()).arg(bm->value(), 0, 'f', 2);
            }

            *out << "</TestFunction>\n";
        }
        *out << "<TestFunction name=\"cleanupTestCase\"><Incident type=\"pass\" file=\"\" line=\"0\"/></TestFunction>\n";
    }
    else {
        for (int i = 0; i <m_testFunctions.count(); ++i) {
            TestFunctionResult *tf = m_testFunctions.at(i);

            QStringList &errors = tf->errors();
            for (int e = 0; e < errors.length(); ++e)
                *out << errors.at(e) << " ";
            if (errors.length() > 0)
                *out << "\n";

            Benchmarks* benchmarks = tf->benchmarks();
            for (int j = 0; j < benchmarks->count(); ++j) {
                *out << tf->name() << " " << benchmarks->at(j)->benchmarkStr() << " " << QString("%1").arg(benchmarks->at(j)->value(), 0, 'f', 2) << "\n";
            }
        }
    }
    if (format == Xml) {
        *out << "</TestCase>\n";
    }

    delete out;
    file.close();
}
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:81,代码来源:resultlogger.cpp


注:本文中的Benchmark::benchmarkStr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。