-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark_iends_with.cpp
50 lines (37 loc) · 1.11 KB
/
benchmark_iends_with.cpp
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
#define CELERO_STATIC
#include <algorithm>
#include <iostream>
#ifdef HAS_BOOST
#include <boost/algorithm/string/predicate.hpp>
#endif
#include "benchmark.hpp"
#include "fixture.hpp"
CELERO_MAIN
STRING_BASELINE(iends_with, strnicmp)
{
celero::DoNotOptimizeAway(fixture::strnicmp(si1.c_str(), si2.c_str(), si1.size()));
assert(si1.size() == si1.size());
assert(fixture::strnicmp(si1.c_str(), si2.c_str(), si1.size()) == 0);
}
STRING_BENCHMARK(iends_with, strnicmp_cstr)
{
celero::DoNotOptimizeAway(fixture::iends_with(si1.c_str(), si2.c_str()));
assert(fixture::iends_with(si1.c_str(), si2.c_str()));
}
STRING_BENCHMARK(iends_with, strnicmp_stdstr)
{
celero::DoNotOptimizeAway(fixture::iends_with(si1, si2));
assert(fixture::iends_with(si1, si2));
}
#ifdef HAS_BOOST
STRING_BENCHMARK(iends_with, boost_cstr)
{
celero::DoNotOptimizeAway(boost::iends_with(si1.c_str(), si2.c_str()));
assert(boost::iends_with(si1, si2));
}
STRING_BENCHMARK(iends_with, boost_stdstr)
{
celero::DoNotOptimizeAway(boost::iends_with(si1, si2));
assert(boost::iends_with(si1, si2));
}
#endif // HAS_BOOST