Add query canonicalization profiling

A small helper program like this helps figure out performance problems
with the function.
This commit is contained in:
Markus Mäkelä 2019-10-10 08:36:43 +03:00
parent dc4e35e60d
commit 067b1cfbc1
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
2 changed files with 48 additions and 0 deletions

View File

@ -1,4 +1,5 @@
add_executable(profile_trxboundaryparser profile_trxboundaryparser.cc)
add_executable(profile_get_canonical profile_get_canonical.cc)
add_executable(test_adminusers test_adminusers.cc)
add_executable(test_atomic test_atomic.cc)
add_executable(test_buffer test_buffer.cc)
@ -26,6 +27,7 @@ add_executable(test_utils test_utils.cc)
add_executable(test_session_track test_session_track.cc)
target_link_libraries(profile_trxboundaryparser maxscale-common)
target_link_libraries(profile_get_canonical maxscale-common)
target_link_libraries(test_adminusers maxscale-common)
target_link_libraries(test_atomic maxscale-common)
target_link_libraries(test_buffer maxscale-common)

View File

@ -0,0 +1,46 @@
/*
* Copyright (c) 2016 MariaDB Corporation Ab
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl11.
*
* Change Date: 2022-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
#include <maxscale/ccdefs.hh>
#include <maxscale/modutil.hh>
#include <iostream>
#include <sstream>
#include <chrono>
using Clock = std::chrono::steady_clock;
using std::chrono::duration_cast;
using std::chrono::milliseconds;
int main(int argc, char* argv[])
{
int ITERATIONS = 10000000;
for (std::string line; std::getline(std::cin, line);)
{
GWBUF* buf = modutil_create_query(line.c_str());
auto start = Clock::now();
for (int i = 0; i < ITERATIONS; i++)
{
auto str = mxs::get_canonical(buf);
}
auto end = Clock::now();
gwbuf_free(buf);
std::cout << line << "\n"
<< duration_cast<milliseconds>(end - start).count() << "ms\n\n";
}
return 0;
}