aboutsummaryrefslogtreecommitdiff
path: root/test/matcherbenchmark
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2019-01-09 19:38:58 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2019-01-09 19:38:58 +0100
commit3d2ae07c455c0e423c64f19e445518427a5684fa (patch)
tree58f6b47c3db33658a6f2e605fd021f08d1fa9964 /test/matcherbenchmark
parentAdd assorted unfished doc files to repo (diff)
downloadsmolbote-3d2ae07c455c0e423c64f19e445518427a5684fa.tar.xz
Rewrite lib/urlfilter
- Make HostList and AdBlockList implementations independent from each other - Move urlfilter tests to lib/urlfilter
Diffstat (limited to 'test/matcherbenchmark')
-rw-r--r--test/matcherbenchmark/matcherbenchmark.cpp91
-rw-r--r--test/matcherbenchmark/matcherbenchmark.h20
2 files changed, 0 insertions, 111 deletions
diff --git a/test/matcherbenchmark/matcherbenchmark.cpp b/test/matcherbenchmark/matcherbenchmark.cpp
deleted file mode 100644
index 84406d5..0000000
--- a/test/matcherbenchmark/matcherbenchmark.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-#include "matcherbenchmark.h"
-#include <string>
-#include <regex>
-#include <regex.h>
-#include <QtTest/QTest>
-#include <QRegExp>
-#include <QRegularExpression>
-#include <QStringMatcher>
-#include <boost/regex.hpp>
-
-void MatcherBenchmark::qstringcontains()
-{
- const QString pattern("spamdomain");
- const QString request("subdomain.spamdomain.com");
-
- QCOMPARE(request.contains(pattern), true);
- QBENCHMARK {
- request.contains(pattern);
- }
-}
-
-void MatcherBenchmark::qstringmatcher()
-{
- const QStringMatcher pattern("spamdomain");
- const QString request("subdomain.spamdomain.com");
-
- QCOMPARE(pattern.indexIn(request) != -1, true);
- QBENCHMARK {
- pattern.indexIn(request);
- }
-}
-
-void MatcherBenchmark::qregexp()
-{
- const QRegExp pattern("spamdomain");
- const QString request("subdomain.spamdomain.com");
-
- QCOMPARE(pattern.indexIn(request) != -1, true);
- QBENCHMARK {
- pattern.indexIn(request);
- }
-}
-
-void MatcherBenchmark::qregularexpressionmatch()
-{
- const QRegularExpression pattern("spamdomain");
- const QString request("subdomain.spamdomain.com");
-
- QCOMPARE(pattern.match(request).hasMatch(), true);
- QBENCHMARK {
- pattern.match(request).hasMatch();
- }
-}
-
-void MatcherBenchmark::stdregex()
-{
- const std::regex pattern("spamdomain");
- const std::string request("subdomain.spamdomain.com");
-
- QCOMPARE(std::regex_search(request, pattern), true);
- QBENCHMARK {
- std::regex_search(request, pattern);
- }
-}
-
-void MatcherBenchmark::cregex()
-{
- regex_t pattern;
- QCOMPARE(regcomp(&pattern, "spamdomain", 0), 0);
- const std::string request("subdomain.spamdomain.com");
-
- QCOMPARE(regexec(&pattern, request.c_str(), 0, NULL, 0), false);
- QBENCHMARK {
- regexec(&pattern, request.c_str(), 0, NULL, 0);
- }
-
- regfree(&pattern);
-}
-
-void MatcherBenchmark::boostregex()
-{
- const boost::regex pattern("spamdomain");
- const std::string request("subdomain.spamdomain.com");
-
- QCOMPARE(boost::regex_search(request, pattern), true);
- QBENCHMARK {
- boost::regex_search(request, pattern);
- }
-}
-
-QTEST_GUILESS_MAIN(MatcherBenchmark)
diff --git a/test/matcherbenchmark/matcherbenchmark.h b/test/matcherbenchmark/matcherbenchmark.h
deleted file mode 100644
index deb4495..0000000
--- a/test/matcherbenchmark/matcherbenchmark.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef MATCHER_BENCHMARK
-#define MATCHER_BENCHMARK
-
-#include <QObject>
-
-class MatcherBenchmark : public QObject
-{
- Q_OBJECT
-
-private slots:
- void qstringcontains();
- void qstringmatcher();
- void qregexp();
- void qregularexpressionmatch();
- void stdregex();
- void cregex();
- void boostregex();
-};
-
-#endif