ANSI: Add benchmark

To have an eye on the parsers performance for
further features, fixes and refactorings.

Change-Id: I6e8ebbd098c9b1c9952416bbe0472fe095bd5d7d
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
Andre Hartmann
2015-07-14 20:54:26 +02:00
committed by André Hartmann
parent d067986b55
commit 302eaf0e69

View File

@@ -58,6 +58,8 @@ private Q_SLOTS:
void testSimpleFormat_data();
void testLineOverlappingFormat();
void testSplitControlSequence();
void oneLineBenchmark();
void multiLineBenchmark();
private:
const QString red;
@@ -303,6 +305,36 @@ void tst_AnsiEscapeCodeHandler::testSplitControlSequence()
QCOMPARE(result[1].format, boldFormat);
}
void tst_AnsiEscapeCodeHandler::oneLineBenchmark()
{
const QString line = QLatin1String("Normal text")
+ mustard256 + QLatin1String(" mustard text ")
+ bold + QLatin1String(" bold text ")
+ grayBackground256 + QLatin1String(" gray background text");
AnsiEscapeCodeHandler handler;
QTextCharFormat defaultFormat;
QBENCHMARK {
handler.parseText(FormattedText(line, defaultFormat));
}
}
void tst_AnsiEscapeCodeHandler::multiLineBenchmark()
{
const QString line1 = QLatin1String("Normal text")
+ mustard256 + QLatin1String(" mustard text ")
+ bold;
const QString line2 = QLatin1String(" bold text ")
+ grayBackground256 + QLatin1String(" gray background text");
AnsiEscapeCodeHandler handler;
QTextCharFormat defaultFormat;
QBENCHMARK {
handler.parseText(FormattedText(line1, defaultFormat));
handler.parseText(FormattedText(line2, defaultFormat));
}
}
QTEST_APPLESS_MAIN(tst_AnsiEscapeCodeHandler)
#include "tst_ansiescapecodehandler.moc"