2015-06-23 15:04:57 +00:00
|
|
|
#include <libsnore/snore.h>
|
|
|
|
#include <libsnore/utils.h>
|
|
|
|
|
|
|
|
#include <QTextDocument>
|
|
|
|
|
|
|
|
#include <QtTest>
|
|
|
|
|
|
|
|
using namespace Snore;
|
|
|
|
|
2015-07-03 09:43:18 +00:00
|
|
|
class SnoreBenchmark : public QObject
|
|
|
|
{
|
2015-06-23 15:04:57 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2015-07-03 09:43:18 +00:00
|
|
|
SnoreBenchmark()
|
|
|
|
{
|
2015-06-23 15:04:57 +00:00
|
|
|
SnoreCore::instance();
|
|
|
|
}
|
|
|
|
|
2015-07-02 12:24:11 +00:00
|
|
|
QString htmlTestString = QLatin1String("<i>Italic A</i><br>"
|
2015-07-03 09:43:18 +00:00
|
|
|
"<i>Italic B</i><br>"
|
|
|
|
"<b>Bold</b><br>"
|
|
|
|
"<u>Underline</u><br>"
|
|
|
|
"<font color=\"blue\">Font</font><br>"
|
|
|
|
"<&><br>"
|
|
|
|
"<a href=\"https://github.com/Snorenotify/Snorenotify\">Website</a><br>");
|
2015-07-02 12:24:11 +00:00
|
|
|
private Q_SLOTS:
|
2015-07-03 09:43:18 +00:00
|
|
|
void benchmarkUtilsToHtml();
|
|
|
|
void benchmarkUtilsToHtmlAllMarkup();
|
|
|
|
void benchmarkUtilsToPlain();
|
2015-06-23 15:04:57 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2015-07-03 09:43:18 +00:00
|
|
|
void SnoreBenchmark::benchmarkUtilsToHtml()
|
|
|
|
{
|
2015-06-23 15:04:57 +00:00
|
|
|
|
2015-07-02 12:24:11 +00:00
|
|
|
QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::NO_MARKUP), QLatin1String("Italic A\n"
|
2015-07-03 09:43:18 +00:00
|
|
|
"Italic B\n"
|
|
|
|
"Bold\n"
|
|
|
|
"Underline\n"
|
|
|
|
"Font\n"
|
|
|
|
"<&>\n"
|
|
|
|
"Website\n"));
|
2015-07-02 12:24:11 +00:00
|
|
|
QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::HREF), QLatin1String("Italic A\n"
|
2015-07-03 09:43:18 +00:00
|
|
|
"Italic B\n"
|
|
|
|
"Bold\n"
|
|
|
|
"Underline\n"
|
|
|
|
"Font\n"
|
|
|
|
"<&>\n"
|
|
|
|
"<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"
|