mirror of
https://github.com/mariadb-corporation/mariadb-connector-cpp.git
synced 2025-07-20 16:35:25 +00:00
[misc] benchmark implementation
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@ -34,6 +34,11 @@ ipch
|
||||
Makefile
|
||||
CPackConfig.cmake
|
||||
CPackSourceConfig.cmake
|
||||
benchmark/benchmark/
|
||||
benchmark/mysql-connector-cpp/
|
||||
benchmark/mariadb.json
|
||||
benchmark/mysql.json
|
||||
benchmark/main-benchmark
|
||||
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
@ -1,5 +1,6 @@
|
||||
os: linux
|
||||
dist: focal
|
||||
sudo: true
|
||||
language: c
|
||||
services: docker
|
||||
addons:
|
||||
@ -59,6 +60,8 @@ jobs:
|
||||
name: "ES 10.4"
|
||||
- env: srv=mariadb-es v=10.5
|
||||
name: "ES 10.5"
|
||||
- env: srv=mariadb v=10.6 local=1 BENCH=true
|
||||
name: "benchmark"
|
||||
- env: srv=maxscale MAXSCALE_TEST_DISABLE=true
|
||||
name: "Maxscale"
|
||||
- env: srv=skysql SKYSQL=true
|
||||
@ -91,4 +94,4 @@ jobs:
|
||||
- env: srv=build
|
||||
name: "CS build"
|
||||
|
||||
script: ./travis.sh
|
||||
script: sudo ./travis.sh
|
||||
|
51
benchmark/README.md
Normal file
51
benchmark/README.md
Normal file
@ -0,0 +1,51 @@
|
||||
# Benchmark MariaDB Connector/C++
|
||||
|
||||
This permits to benchmark MariaDB connector/C++, comparing with MySQL connector
|
||||
|
||||
## Installation
|
||||
To install google benchmark, mysql connector and build current connector :
|
||||
```script
|
||||
sudo benchmark/build.sh
|
||||
cd benchmark
|
||||
sudo ./installation.sh
|
||||
```
|
||||
|
||||
## Basic run
|
||||
|
||||
This will runs the benchmark with 50 repetition to ensure stability then display results
|
||||
```script
|
||||
sudo ./launch.sh
|
||||
```
|
||||
|
||||
## detailed benchmark
|
||||
|
||||
first ensure running cpu to maximum speed:
|
||||
```script
|
||||
sudo cpupower frequency-set --governor performance || true
|
||||
```
|
||||
|
||||
launch a server:
|
||||
```script
|
||||
sudo docker run --name mariadb-bench -e MARIADB_DATABASE=bench -e MARIADB_USER=example-user -e MARIADB_PASSWORD=my_cool_secret -e MARIADB_ROOT_PASSWORD=my-secret-pw -p 3806:3306 -d mariadb:latest --max_connections=10000 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --innodb_flush_log_at_trx_commit=2 --innodb_doublewrite=0 --innodb_log_file_size=10G --innodb_buffer_pool_size=10G --thread_handling=pool-of-threads --max_heap_table_size=6G --tmp_table_size=6G --innodb_io_capacity=30000
|
||||
```
|
||||
|
||||
default is benchmarking on one thread. adding benchmark on multiple thread can be done setting MAX_THREAD in main-benchmark.cc. Setting it to 256, benchmark will run on 1 to 256 threads.
|
||||
|
||||
running with MariaDB driver:
|
||||
```script
|
||||
g++ main-benchmark.cc -std=c++11 -isystem benchmark/include -Lbenchmark/build/src -L/usr/local/lib/mariadb/ -lbenchmark -lpthread -lmariadbcpp -o main-benchmark
|
||||
./main-benchmark --benchmark_repetitions=50 --benchmark_time_unit=us --benchmark_min_warmup_time=10 --benchmark_counters_tabular=true --benchmark_format=json --benchmark_out=mariadb.json
|
||||
```
|
||||
|
||||
running with MySQL driver:
|
||||
```script
|
||||
g++ main-benchmark.cc -std=c++11 -isystem benchmark/include -Lbenchmark/build/src -lbenchmark -lpthread -DMYSQL -lmysqlcppconn -o main-benchmark
|
||||
./main-benchmark --benchmark_repetitions=50 --benchmark_time_unit=us --benchmark_min_warmup_time=10 --benchmark_counters_tabular=true --benchmark_format=json --benchmark_out=mysql.json
|
||||
```
|
||||
|
||||
in order to compare results:
|
||||
|
||||
```script
|
||||
pip3 install -r benchmark/requirements.txt
|
||||
benchmark/tools/compare.py -a --no-utest benchmarksfiltered ./mysql.json MySQL ./mariadb.json MariaDB
|
||||
```
|
36
benchmark/build.sh
Executable file
36
benchmark/build.sh
Executable file
@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
sudo apt-get update
|
||||
sudo apt-get -f -y install build-essential cmake
|
||||
sudo apt-get -f -y install libmariadb3 libmariadb-dev
|
||||
sudo apt-get -f -y install linux-tools-common linux-gcp linux-tools-$(uname -r)
|
||||
cmake . -DCONC_WITH_MSI=OFF -DCONC_WITH_UNIT_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DWITH_SSL=OPENSSL
|
||||
sudo cmake --build . --config Release --target install
|
||||
sudo make install
|
||||
echo $LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=/usr/local/lib
|
||||
sudo install /usr/local/lib/mariadb/libmariadbcpp.so /usr/lib
|
||||
sudo install -d /usr/lib/mariadb
|
||||
sudo install -d /usr/lib/mariadb/plugin
|
||||
|
||||
sudo ldconfig -n /usr/local/lib/mariadb || true
|
||||
sudo ldconfig -l -v /usr/lib/libmariadbcpp.so || true
|
||||
|
||||
ls -lrt /usr/lib/libmar*
|
||||
|
||||
#ldconfig -p
|
||||
|
||||
#install mysql
|
||||
#git clone --recurse-submodules https://github.com/mysql/mysql-connector-cpp.git
|
||||
#cd mysql-connector-cpp
|
||||
#git checkout 8.0
|
||||
#
|
||||
#sudo apt-get install libboost-all-dev
|
||||
#
|
||||
#cmake . -DCMAKE_BUILD_TYPE=Release -DWITH_JDBC=ON -DWITH_BOOST=/usr/include/boost
|
||||
#sudo cmake --build . --target install --config Release
|
||||
|
||||
|
||||
sudo apt-get -y install libmysqlcppconn-dev
|
17
benchmark/installation.sh
Executable file
17
benchmark/installation.sh
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
# Check out the library.
|
||||
git clone https://github.com/google/benchmark.git
|
||||
# Go to the library root directory
|
||||
cd benchmark
|
||||
# Make a build directory to place the build output.
|
||||
cmake -E make_directory "build"
|
||||
# Generate build system files with cmake, and download any dependencies.
|
||||
cmake -E chdir "build" cmake -DBENCHMARK_DOWNLOAD_DEPENDENCIES=on -DCMAKE_BUILD_TYPE=Release ../
|
||||
# or, starting with CMake 3.13, use a simpler form:
|
||||
# cmake -DCMAKE_BUILD_TYPE=Release -S . -B "build"
|
||||
# Build the library.
|
||||
cmake --build "build" --config Release
|
||||
|
15
benchmark/launch.sh
Executable file
15
benchmark/launch.sh
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
sudo cpupower frequency-set --governor performance || true
|
||||
|
||||
g++ main-benchmark.cc -std=c++11 -isystem benchmark/include -Lbenchmark/build/src -L/usr/local/lib/mariadb/ -lbenchmark -lpthread -lmariadbcpp -o main-benchmark
|
||||
./main-benchmark --benchmark_repetitions=30 --benchmark_time_unit=us --benchmark_min_warmup_time=10 --benchmark_counters_tabular=true --benchmark_format=json --benchmark_out=mariadb.json
|
||||
|
||||
g++ main-benchmark.cc -std=c++11 -isystem benchmark/include -Lbenchmark/build/src -lbenchmark -lpthread -DMYSQL -lmysqlcppconn -o main-benchmark
|
||||
./main-benchmark --benchmark_repetitions=30 --benchmark_time_unit=us --benchmark_min_warmup_time=10 --benchmark_counters_tabular=true --benchmark_format=json --benchmark_out=mysql.json
|
||||
|
||||
|
||||
pip3 install -r benchmark/requirements.txt
|
||||
benchmark/tools/compare.py -a --no-utest benchmarksfiltered ./mysql.json MySQL ./mariadb.json MariaDB
|
279
benchmark/main-benchmark.cc
Normal file
279
benchmark/main-benchmark.cc
Normal file
@ -0,0 +1,279 @@
|
||||
#include <benchmark/benchmark.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <stdlib.h>
|
||||
|
||||
const int MAX_THREAD = 1;
|
||||
#define OPERATION_PER_SECOND_LABEL "nb operations per second"
|
||||
|
||||
std::string GetEnvironmentVariableOrDefault(const std::string& variable_name,
|
||||
const std::string& default_value)
|
||||
{
|
||||
const char* value = getenv(variable_name.c_str());
|
||||
return value ? value : default_value;
|
||||
}
|
||||
|
||||
std::string DB_PORT = GetEnvironmentVariableOrDefault("TEST_DB_PORT", "3306");
|
||||
std::string DB_DATABASE = GetEnvironmentVariableOrDefault("TEST_DB_DATABASE", "bench");
|
||||
std::string DB_USER = GetEnvironmentVariableOrDefault("TEST_DB_USER", "root");
|
||||
std::string DB_HOST = GetEnvironmentVariableOrDefault("TEST_DB_HOST", "localhost");
|
||||
std::string DB_PASSWORD = GetEnvironmentVariableOrDefault("TEST_DB_PASSWORD", "");
|
||||
|
||||
#ifndef MYSQL
|
||||
#include <mariadb/conncpp.hpp>
|
||||
const std::string TYPE = "MariaDB";
|
||||
sql::Connection* connect(std::string options) {
|
||||
try {
|
||||
sql::Connection *con;
|
||||
sql::Driver *driver;
|
||||
|
||||
// Instantiate Driver
|
||||
driver = sql::mariadb::get_driver_instance();
|
||||
|
||||
// Establish Connection
|
||||
con = driver->connect("tcp://" + DB_HOST + ":" + DB_PORT + "/" + DB_DATABASE + options, DB_USER, DB_PASSWORD);
|
||||
return con;
|
||||
|
||||
} catch(sql::SQLException& e){
|
||||
std::cerr << "Error Connecting to MariaDB Platform: " << e.what() << std::endl;
|
||||
// Exit (Failed)
|
||||
exit(1) ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MYSQL
|
||||
#include "mysql_connection.h"
|
||||
#include <cppconn/driver.h>
|
||||
#include <cppconn/exception.h>
|
||||
#include <cppconn/resultset.h>
|
||||
#include <cppconn/statement.h>
|
||||
#include <cppconn/prepared_statement.h>
|
||||
const std::string TYPE = "MySQL";
|
||||
sql::Connection* connect(std::string options) {
|
||||
try {
|
||||
sql::Connection *con;
|
||||
sql::Driver *driver;
|
||||
|
||||
// Instantiate Driver
|
||||
driver = get_driver_instance();
|
||||
//sql::mariadb::get_driver_instance();
|
||||
|
||||
// Configure Connection
|
||||
|
||||
// Establish Connection
|
||||
con = driver->connect("tcp://" + DB_HOST + ":" + DB_PORT + "/" + DB_DATABASE + options, DB_USER, DB_PASSWORD);
|
||||
return con;
|
||||
|
||||
} catch(sql::SQLException& e){
|
||||
std::cerr << "Error Connecting to MySQL Platform: " << e.what() << std::endl;
|
||||
// Exit (Failed)
|
||||
exit(1) ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void do_1(benchmark::State& state, sql::Connection* conn) {
|
||||
try {
|
||||
sql::Statement *stmt;
|
||||
sql::ResultSet *res;
|
||||
|
||||
// Create a new Statement
|
||||
stmt = conn->createStatement();
|
||||
// Execute query
|
||||
stmt->executeUpdate("DO 1");
|
||||
delete stmt;
|
||||
} catch(sql::SQLException& e){
|
||||
state.SkipWithError(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
static void BM_DO_1(benchmark::State& state) {
|
||||
sql::Connection *conn = connect("");
|
||||
int numOperation = 0;
|
||||
for (auto _ : state) {
|
||||
do_1(state, conn);
|
||||
numOperation++;
|
||||
}
|
||||
state.counters[OPERATION_PER_SECOND_LABEL] = benchmark::Counter(numOperation, benchmark::Counter::kIsRate);
|
||||
delete conn;
|
||||
}
|
||||
|
||||
BENCHMARK(BM_DO_1)->Name(TYPE + " DO 1")->ThreadRange(1, MAX_THREAD)->UseRealTime();
|
||||
|
||||
int select_1(benchmark::State& state, sql::Connection* conn) {
|
||||
int val;
|
||||
try {
|
||||
sql::Statement *stmt;
|
||||
sql::ResultSet *res;
|
||||
|
||||
// Create a new Statement
|
||||
stmt = conn->createStatement();
|
||||
// Execute query
|
||||
res = stmt->executeQuery("SELECT 1");
|
||||
// Loop through results
|
||||
while (res->next()) {
|
||||
val = res->getInt(1);
|
||||
}
|
||||
delete res;
|
||||
delete stmt;
|
||||
} catch(sql::SQLException& e){
|
||||
state.SkipWithError(e.what());
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
static void BM_SELECT_1(benchmark::State& state) {
|
||||
sql::Connection *conn = connect("");
|
||||
int numOperation = 0;
|
||||
for (auto _ : state) {
|
||||
benchmark::DoNotOptimize(select_1(state, conn));
|
||||
benchmark::ClobberMemory();
|
||||
numOperation++;
|
||||
}
|
||||
state.counters[OPERATION_PER_SECOND_LABEL] = benchmark::Counter(numOperation, benchmark::Counter::kIsRate);
|
||||
delete conn;
|
||||
}
|
||||
|
||||
BENCHMARK(BM_SELECT_1)->Name(TYPE + " SELECT 1")->ThreadRange(1, MAX_THREAD)->UseRealTime();
|
||||
|
||||
void select_1000_rows(benchmark::State& state, sql::Connection* conn) {
|
||||
try {
|
||||
sql::Statement *stmt;
|
||||
sql::ResultSet *res;
|
||||
|
||||
// Create a new Statement
|
||||
stmt = conn->createStatement();
|
||||
// stmt->setFetchSize(1); => error if set
|
||||
// Execute query
|
||||
res = stmt->executeQuery("select seq, 'abcdefghijabcdefghijabcdefghijaa' from seq_1_to_1000");
|
||||
|
||||
// Loop through results
|
||||
int val1;
|
||||
sql::SQLString val2;
|
||||
while (res->next()) {
|
||||
benchmark::DoNotOptimize(val1 = res->getInt(1));
|
||||
benchmark::DoNotOptimize(val2 = res->getString(2));
|
||||
benchmark::ClobberMemory();
|
||||
}
|
||||
delete res;
|
||||
delete stmt;
|
||||
} catch(sql::SQLException& e){
|
||||
state.SkipWithError(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
static void BM_SELECT_1000_ROWS(benchmark::State& state) {
|
||||
sql::Connection *conn = connect("");
|
||||
int numOperation = 0;
|
||||
for (auto _ : state) {
|
||||
select_1000_rows(state, conn);
|
||||
numOperation++;
|
||||
}
|
||||
state.counters[OPERATION_PER_SECOND_LABEL] = benchmark::Counter(numOperation, benchmark::Counter::kIsRate);
|
||||
delete conn;
|
||||
}
|
||||
|
||||
BENCHMARK(BM_SELECT_1000_ROWS)->Name(TYPE + " SELECT 1000 rows (int + char(32))")->ThreadRange(1, MAX_THREAD)->UseRealTime();
|
||||
|
||||
static void setup_select_100_cols(const benchmark::State& state) {
|
||||
sql::Connection *conn = connect("");
|
||||
|
||||
// initialize data
|
||||
sql::Statement *stmt;
|
||||
stmt = conn->createStatement();
|
||||
stmt->executeUpdate("DROP TABLE IF EXISTS test100");
|
||||
stmt->execute("CREATE TABLE test100 (i1 int,i2 int,i3 int,i4 int,i5 int,i6 int,i7 int,i8 int,i9 int,i10 int,i11 int,i12 int,i13 int,i14 int,i15 int,i16 int,i17 int,i18 int,i19 int,i20 int,i21 int,i22 int,i23 int,i24 int,i25 int,i26 int,i27 int,i28 int,i29 int,i30 int,i31 int,i32 int,i33 int,i34 int,i35 int,i36 int,i37 int,i38 int,i39 int,i40 int,i41 int,i42 int,i43 int,i44 int,i45 int,i46 int,i47 int,i48 int,i49 int,i50 int,i51 int,i52 int,i53 int,i54 int,i55 int,i56 int,i57 int,i58 int,i59 int,i60 int,i61 int,i62 int,i63 int,i64 int,i65 int,i66 int,i67 int,i68 int,i69 int,i70 int,i71 int,i72 int,i73 int,i74 int,i75 int,i76 int,i77 int,i78 int,i79 int,i80 int,i81 int,i82 int,i83 int,i84 int,i85 int,i86 int,i87 int,i88 int,i89 int,i90 int,i91 int,i92 int,i93 int,i94 int,i95 int,i96 int,i97 int,i98 int,i99 int,i100 int)");
|
||||
stmt->execute("INSERT INTO test100 value (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100)");
|
||||
delete stmt;
|
||||
delete conn;
|
||||
}
|
||||
|
||||
|
||||
void select_100_cols(benchmark::State& state, sql::Connection* conn) {
|
||||
try {
|
||||
sql::PreparedStatement *prep_stmt;
|
||||
sql::ResultSet *res;
|
||||
|
||||
// Create a new Statement
|
||||
prep_stmt = conn->prepareStatement("select * FROM test100");
|
||||
// Execute query
|
||||
res = prep_stmt->executeQuery();
|
||||
// Loop through results
|
||||
int val;
|
||||
while (res->next()) {
|
||||
for (int i=1; i<=100; i++)
|
||||
benchmark::DoNotOptimize(val = res->getInt(i));
|
||||
benchmark::ClobberMemory();
|
||||
}
|
||||
delete res;
|
||||
delete prep_stmt;
|
||||
} catch(sql::SQLException& e){
|
||||
state.SkipWithError(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
static void BM_SELECT_100_COLS(benchmark::State& state) {
|
||||
sql::Connection *conn = connect("");
|
||||
int numOperation = 0;
|
||||
for (auto _ : state) {
|
||||
select_100_cols(state, conn);
|
||||
numOperation++;
|
||||
}
|
||||
state.counters[OPERATION_PER_SECOND_LABEL] = benchmark::Counter(numOperation, benchmark::Counter::kIsRate);
|
||||
delete conn;
|
||||
}
|
||||
static void BM_SELECT_100_COLS_SRV_PREPARED(benchmark::State& state) {
|
||||
sql::Connection *conn = connect("?useServerPrepStmts=true");
|
||||
int numOperation = 0;
|
||||
for (auto _ : state) {
|
||||
select_100_cols(state, conn);
|
||||
numOperation++;
|
||||
}
|
||||
state.counters[OPERATION_PER_SECOND_LABEL] = benchmark::Counter(numOperation, benchmark::Counter::kIsRate);
|
||||
delete conn;
|
||||
}
|
||||
|
||||
BENCHMARK(BM_SELECT_100_COLS)->Name(TYPE + " SELECT 100 int cols")->ThreadRange(1, MAX_THREAD)->UseRealTime()->Setup(setup_select_100_cols);
|
||||
#ifndef MYSQL
|
||||
BENCHMARK(BM_SELECT_100_COLS_SRV_PREPARED)->Name(TYPE + " SELECT 100 int cols - srv prepared")->ThreadRange(1, MAX_THREAD)->UseRealTime();
|
||||
#endif
|
||||
|
||||
|
||||
void do_1000_params(benchmark::State& state, sql::Connection* conn) {
|
||||
try {
|
||||
sql::PreparedStatement *prep_stmt;
|
||||
sql::ResultSet *res;
|
||||
|
||||
// Create a new Statement
|
||||
prep_stmt = conn->prepareStatement(
|
||||
"DO ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?"
|
||||
);
|
||||
for (int i=1; i<=1000; i++) {
|
||||
prep_stmt->setInt(i, i);
|
||||
}
|
||||
|
||||
// Execute query
|
||||
prep_stmt->execute();
|
||||
delete prep_stmt;
|
||||
} catch(sql::SQLException& e){
|
||||
state.SkipWithError(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
static void BM_DO_1000_PARAMS(benchmark::State& state) {
|
||||
sql::Connection *conn = connect("");
|
||||
int numOperation = 0;
|
||||
for (auto _ : state) {
|
||||
do_1000_params(state, conn);
|
||||
numOperation++;
|
||||
}
|
||||
state.counters[OPERATION_PER_SECOND_LABEL] = benchmark::Counter(numOperation, benchmark::Counter::kIsRate);
|
||||
delete conn;
|
||||
}
|
||||
|
||||
BENCHMARK(BM_DO_1000_PARAMS)->Name(TYPE + " DO 1000 params")->ThreadRange(1, MAX_THREAD)->UseRealTime();
|
||||
|
||||
BENCHMARK_MAIN();
|
||||
|
12
travis.sh
12
travis.sh
@ -1,6 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -ex
|
||||
|
||||
if [ -n "$BENCH" ] ; then
|
||||
sudo benchmark/build.sh
|
||||
cd benchmark
|
||||
sudo ./installation.sh
|
||||
sudo ./launch.sh
|
||||
exit
|
||||
fi
|
||||
|
||||
# Setting test environment before building connector to configure tests default credentials
|
||||
if [ "$TRAVIS_OS_NAME" = "windows" ] ; then
|
||||
@ -30,6 +38,8 @@ if [ "${TEST_REQUIRE_TLS}" = "1" ] ; then
|
||||
export TEST_USETLS=true
|
||||
fi
|
||||
|
||||
sudo apt install cmake
|
||||
|
||||
if [ "$TRAVIS_OS_NAME" = "windows" ] ; then
|
||||
cmake -DCONC_WITH_MSI=OFF -DCONC_WITH_UNIT_TESTS=OFF -DWITH_MSI=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_SSL=SCHANNEL -DTEST_HOST="jdbc:mariadb://$TEST_DB_HOST:$TEST_DB_PORT" .
|
||||
else
|
||||
|
Reference in New Issue
Block a user