mirror of
https://github.com/pocoproject/poco.git
synced 2025-05-25 14:34:04 +02:00

* fix(SQLParser): move to Data dir; add extradirs, remove vs 140,150 build scripts generation * fix(ActiveRecord): Makefile #4453 * fix(Data): Make SQLParser internal * fix(build): ODBC Makefile and Data libs CmakeLists #4453 * fix(build): Data libs CMakeLists #4453 * fix(build): regenerate VS projects #4453 * fix(CppUnit): remove Foundation dependency * fix(SQLParser): remove leftover unnecessary includes * fix(SQLParser): remove fwd header #4453 * fix(PocoDoc): remove SQLParser from include list * fix(mkrelease): remove 140,150 vs projects * fix(SQLParser): Disable SQL parsing by default #4462 * fix(test): Disable SQL parsing by default #4462 * Fix detection of odbc and apache2 for Fedora (#4461) * Fixed transaction handling in MySQL test when SQL parser is switched off * chore(ParallelSocketAcceptor): remove unnecessary include and using from header --------- Co-authored-by: Matej Kenda <matejken@gmail.com> Co-authored-by: topazus <77263945+topazus@users.noreply.github.com> Co-authored-by: Friedrich Wilckens <frwilckens@gmail.com>
45 lines
1.2 KiB
C++
45 lines
1.2 KiB
C++
#include "benchmark_utils.h"
|
|
|
|
#include <fstream>
|
|
#include <iostream>
|
|
|
|
#include "SQLParser.h"
|
|
|
|
size_t getNumTokens(const std::string& query) {
|
|
std::vector<int16_t> tokens;
|
|
hsql::SQLParser::tokenize(query, &tokens);
|
|
return tokens.size();
|
|
}
|
|
|
|
void BM_TokenizeBenchmark(benchmark::State& st, const std::string& query) {
|
|
st.counters["num_tokens"] = getNumTokens(query);
|
|
st.counters["num_chars"] = query.size();
|
|
|
|
while (st.KeepRunning()) {
|
|
std::vector<int16_t> tokens(512);
|
|
hsql::SQLParser::tokenize(query, &tokens);
|
|
}
|
|
}
|
|
|
|
void BM_ParseBenchmark(benchmark::State& st, const std::string& query) {
|
|
st.counters["num_tokens"] = getNumTokens(query);
|
|
st.counters["num_chars"] = query.size();
|
|
|
|
while (st.KeepRunning()) {
|
|
hsql::SQLParserResult result;
|
|
hsql::SQLParser::parse(query, &result);
|
|
if (!result.isValid()) {
|
|
std::cout << query << std::endl;
|
|
std::cout << result.errorMsg() << std::endl;
|
|
st.SkipWithError("Parsing failed!");
|
|
}
|
|
}
|
|
}
|
|
|
|
std::string readFileContents(const std::string& file_path) {
|
|
std::ifstream t(file_path.c_str());
|
|
std::string text((std::istreambuf_iterator<char>(t)),
|
|
std::istreambuf_iterator<char>());
|
|
return text;
|
|
}
|