blob: cb4feb1806ee6358a711ae0cbf97d85f18d7e8d6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#include "matcherbenchmark.h"
#include <QtTest/QTest>
#include <QRegExp>
#include <QRegularExpression>
#include <QStringMatcher>
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 {
QCOMPARE(pattern.match(request).hasMatch(), true);
}
}
QTEST_GUILESS_MAIN(MatcherBenchmark)
|