forked from qt-creator/qt-creator
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:
committed by
André Hartmann
parent
d067986b55
commit
302eaf0e69
@@ -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"
|
||||
|
Reference in New Issue
Block a user