Try out dfa for numbers

This commit is contained in:
2025-06-19 16:13:46 -04:00
parent e1ba8e9fa8
commit 976f64b7d3
2 changed files with 159 additions and 225 deletions

View File

@@ -12,6 +12,7 @@
#include <simdjson.h>
#include "callbacks.h"
#include "parser3.h"
#include "weaseljson.h"
// This is the JSON grammar in McKeeman Form.
@@ -306,3 +307,21 @@ TEST_CASE("bench5") {
bench.doNotOptimizeAway(doc);
});
}
TEST_CASE("num dfa") {
parser3::NumDfa dfa;
std::string match = "-1231279127389127389127398127389712893791287389217327482"
"374.0e69010101010101010101010101010101";
auto *buf = dfa.scan(match.data(), match.data() + match.size());
CHECK(buf == match.data() + match.size());
CHECK(dfa.accept());
ankerl::nanobench::Bench bench;
bench.batch(match.size());
bench.unit("byte");
bench.run("number dfa", [&]() {
dfa.reset();
bench.doNotOptimizeAway(
dfa.scan(match.data(), match.data() + match.size()));
});
}