本文整理汇总了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();
}