diff options
Diffstat (limited to 'test/matcherbenchmark/matcherbenchmark.cpp')
-rw-r--r-- | test/matcherbenchmark/matcherbenchmark.cpp | 91 |
1 files changed, 0 insertions, 91 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) |