aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test/benchmarks/lexer.cpp
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-01-03 03:21:50 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2020-01-03 03:21:50 +0300
commit0df5875a0ea49c4e7e05274d180b07f5cb56743d (patch)
treedbc2da0da3a42c5253aa62aec61aaa1c18ec0483 /test/benchmarks/lexer.cpp
parentadd Google's benchmark library as a submodule (diff)
downloadmath-server-0df5875a0ea49c4e7e05274d180b07f5cb56743d.tar.gz
math-server-0df5875a0ea49c4e7e05274d180b07f5cb56743d.zip
add a basic benchmark for lexer
I suspect std::regex is _horribly_ slow. Will compare it to boost::regex, then decide.
Diffstat (limited to '')
-rw-r--r--test/benchmarks/lexer.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/benchmarks/lexer.cpp b/test/benchmarks/lexer.cpp
new file mode 100644
index 0000000..0f3151f
--- /dev/null
+++ b/test/benchmarks/lexer.cpp
@@ -0,0 +1,25 @@
+#include <server/lexer/details/parse.hpp>
+
+#include <benchmark/benchmark.h>
+
+class SelectionOfNumbers : public benchmark::Fixture {
+protected:
+ std::vector<std::string_view> m_numbers{
+ "0",
+ "123",
+ "0.123",
+ ".123",
+ "1e9",
+ "1.87E-18",
+ "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789",
+ };
+};
+
+BENCHMARK_F(SelectionOfNumbers, ParseStdRegex)(benchmark::State &state) {
+ using namespace math::server::lexer::details;
+ for (auto _ : state) {
+ for (const auto& src : m_numbers) {
+ parse_number(src);
+ }
+ }
+}