aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-01-06 13:40:22 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2020-01-06 14:38:46 +0300
commit5c11d731cadd06204c8c6d6c1aea2253450204a8 (patch)
tree4bbea3a2f1180c39e958f9dad109ebf4adfe4e05 /test
parentlexer: switch to Boost.Regex (diff)
downloadmath-server-5c11d731cadd06204c8c6d6c1aea2253450204a8.tar.gz
math-server-5c11d731cadd06204c8c6d6c1aea2253450204a8.zip
lexer: std:: vs boost:: for whitespace parsing
Added the corresponding benchmarks too.
Diffstat (limited to '')
-rw-r--r--test/benchmarks/lexer.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/test/benchmarks/lexer.cpp b/test/benchmarks/lexer.cpp
index 4279d8b..3eb895c 100644
--- a/test/benchmarks/lexer.cpp
+++ b/test/benchmarks/lexer.cpp
@@ -2,7 +2,7 @@
#include <benchmark/benchmark.h>
-class SelectionOfNumbers : public benchmark::Fixture {
+class NumberExamples : public benchmark::Fixture {
protected:
std::vector<std::string_view> m_numbers{
"0",
@@ -15,7 +15,16 @@ protected:
};
};
-BENCHMARK_F(SelectionOfNumbers, ParseStdRegex)(benchmark::State& state) {
+class WhitespaceExamples : public benchmark::Fixture {
+protected:
+ std::vector<std::string_view> m_whitespace{
+ "",
+ " 1",
+ " 123",
+ };
+};
+
+BENCHMARK_F(NumberExamples, StdParseNumber)(benchmark::State& state) {
using namespace math::server::lexer::details;
for (auto _ : state) {
for (const auto& src : m_numbers) {
@@ -24,7 +33,7 @@ BENCHMARK_F(SelectionOfNumbers, ParseStdRegex)(benchmark::State& state) {
}
}
-BENCHMARK_F(SelectionOfNumbers, ParseBoostRegex)(benchmark::State& state) {
+BENCHMARK_F(NumberExamples, BoostParseNumber)(benchmark::State& state) {
using namespace math::server::lexer::details;
for (auto _ : state) {
for (const auto& src : m_numbers) {
@@ -32,3 +41,21 @@ BENCHMARK_F(SelectionOfNumbers, ParseBoostRegex)(benchmark::State& state) {
}
}
}
+
+BENCHMARK_F(WhitespaceExamples, StdParseWhitespace)(benchmark::State& state) {
+ using namespace math::server::lexer::details;
+ for (auto _ : state) {
+ for (const auto& src : m_whitespace) {
+ impl::std_parse_whitespace(src);
+ }
+ }
+}
+
+BENCHMARK_F(WhitespaceExamples, BoostParseWhitespace)(benchmark::State& state) {
+ using namespace math::server::lexer::details;
+ for (auto _ : state) {
+ for (const auto& src : m_whitespace) {
+ impl::boost_parse_whitespace(src);
+ }
+ }
+}