2015-06-23 15:04:57 +00:00
|
|
|
#include <libsnore/snore.h>
|
|
|
|
#include <libsnore/utils.h>
|
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
#include <QTextDocument>
|
|
|
|
#include <QTextDocumentFragment>
|
|
|
|
|
|
|
|
#include <QtTest>
|
|
|
|
|
|
|
|
using namespace Snore;
|
|
|
|
|
|
|
|
|
|
|
|
class SnoreBenchmark : public QObject{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
SnoreBenchmark(){
|
|
|
|
SnoreCore::instance();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString htmlTestString = QString("<i>Italic A</i><br>"
|
|
|
|
"<i>Italic B</i><br>"
|
|
|
|
"<b>Bold</b><br>"
|
|
|
|
"<u>Underline</u><br>"
|
|
|
|
"<font color=\"blue\">Font</font><br>"
|
2015-06-26 13:59:58 +00:00
|
|
|
"<&><br>"
|
2015-06-23 15:04:57 +00:00
|
|
|
"<a href=\"https://github.com/Snorenotify/Snorenotify\">Website</a><br>");
|
|
|
|
private slots:
|
|
|
|
void benchmarkUtilsToHtml();
|
2015-06-23 15:13:01 +00:00
|
|
|
void benchmarkUtilsToHtmlAllMarkup();
|
2015-06-23 15:04:57 +00:00
|
|
|
void benchmarkUtilsToPlain();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void SnoreBenchmark::benchmarkUtilsToHtml(){
|
|
|
|
|
|
|
|
|
2015-06-29 10:09:34 +00:00
|
|
|
QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::NO_MARKUP), QString("Italic A\n"
|
2015-06-26 13:59:58 +00:00
|
|
|
"Italic B\n"
|
|
|
|
"Bold\n"
|
|
|
|
"Underline\n"
|
|
|
|
"Font\n"
|
|
|
|
"<&>\n"
|
|
|
|
"Website\n"));
|
2015-06-29 10:09:34 +00:00
|
|
|
QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::HREF), QString("Italic A\n"
|
2015-06-23 15:04:57 +00:00
|
|
|
"Italic B\n"
|
|
|
|
"Bold\n"
|
|
|
|
"Underline\n"
|
|
|
|
"Font\n"
|
2015-06-26 13:59:58 +00:00
|
|
|
"<&>\n"
|
2015-06-23 15:04:57 +00:00
|
|
|
"<a href=\"https://github.com/Snorenotify/Snorenotify\">Website</a>\n"));
|
2015-06-29 10:09:34 +00:00
|
|
|
QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::HREF | Utils::BOLD | Utils::BREAK |
|
2015-06-23 15:04:57 +00:00
|
|
|
Utils::UNDERLINE | Utils::FONT | Utils::ITALIC), htmlTestString);
|
|
|
|
QBENCHMARK{
|
2015-06-29 10:09:34 +00:00
|
|
|
Utils::normalizeMarkup(htmlTestString, Utils::HREF);
|
2015-06-23 15:04:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-23 15:13:01 +00:00
|
|
|
void SnoreBenchmark::benchmarkUtilsToHtmlAllMarkup()
|
|
|
|
{
|
2015-06-29 10:09:34 +00:00
|
|
|
QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::ALL_MARKUP), htmlTestString);
|
2015-06-23 15:13:01 +00:00
|
|
|
|
|
|
|
QBENCHMARK{
|
2015-06-29 10:09:34 +00:00
|
|
|
Utils::normalizeMarkup(htmlTestString, Utils::ALL_MARKUP);
|
2015-06-23 15:13:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-23 15:04:57 +00:00
|
|
|
void SnoreBenchmark::benchmarkUtilsToPlain()
|
|
|
|
{
|
|
|
|
QBENCHMARK{
|
2015-06-29 10:09:34 +00:00
|
|
|
Utils::normalizeMarkup(htmlTestString, Utils::NO_MARKUP);
|
2015-06-23 15:04:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
QTEST_MAIN(SnoreBenchmark)
|
|
|
|
|
|
|
|
#include "snorebenchmark.moc"
|