From a409b713234e4342315619f044b7a1e8fba93496 Mon Sep 17 00:00:00 2001 From: rusher Date: Tue, 12 Sep 2023 12:51:10 +0200 Subject: [PATCH] [misc] benchmark improvement to use same server charset. mysql/mysql2 use fixed UTF8_GENERAL_CI, in place of default utf8mb4 charset. This is now corrected. --- benchmarks/common-bench.js | 23 ++++++++++++++++------- benchmarks/log-utility.js | 4 +++- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/benchmarks/common-bench.js b/benchmarks/common-bench.js index 7f4e06fe..d268032e 100644 --- a/benchmarks/common-bench.js +++ b/benchmarks/common-bench.js @@ -17,12 +17,15 @@ try { } catch (e) {} //************************************************ -// COMMON CONFIGURATION +// COMMON CONFIGURATION. +// Mysql and Mysql2 doesn't use server collation, but fixed collation UTF8_GENERAL_CI. +// setting it to default utf8mb4 collation, to be fair //************************************************ const conf = require('../test/conf'); const logUtility = require('./log-utility'); const config = Object.assign({}, conf.baseConfig, { trace: false }); -console.log(config); + +let configWithCharset = null; const minimumSamples = process.env.PERF_SAMPLES ? parseInt(process.env.PERF_SAMPLES) : 200; //************************************************ @@ -90,22 +93,28 @@ const createBenchSuite = async (bench) => { //************************************************ const loadsources = async (requiresPool, requireExecute, mariadbOnly) => { const sources = {}; + sources['mariadb'] = await mariadb.createConnection(Object.assign({}, config)); + if (!configWithCharset && sources['mariadb'].info.collation) { + const collation = sources['mariadb'].info.collation.name; + configWithCharset = Object.assign({}, conf.baseConfig, { trace: false, charset: collation }); + console.log(configWithCharset); + } + if (requiresPool == undefined || requiresPool === false) { if (mysql) { if (!mariadbOnly && (requireExecute == undefined || requireExecute === false)) { - sources['mysql'] = await mysql.createConnection(Object.assign({}, config)); + sources['mysql'] = await mysql.createConnection(Object.assign({}, configWithCharset)); } } if (mysql2 && !mariadbOnly) { - sources['mysql2'] = await mysql2.createConnection(Object.assign({}, config)); + sources['mysql2'] = await mysql2.createConnection(Object.assign({}, configWithCharset)); } - sources['mariadb'] = await mariadb.createConnection(Object.assign({}, config)); } else { if (!mariadbOnly && mysql) { - sources['mysql'] = await mysql.createPool(Object.assign({ connectionLimit: 1 }, config)); + sources['mysql'] = await mysql.createPool(Object.assign({ connectionLimit: 1 }, configWithCharset)); } if (!mariadbOnly && mysql2) { - sources['mysql2'] = mysql2.createPool(Object.assign({ connectionLimit: 1 }, config)); + sources['mysql2'] = mysql2.createPool(Object.assign({ connectionLimit: 1 }, configWithCharset)); } } diff --git a/benchmarks/log-utility.js b/benchmarks/log-utility.js index a912d690..f159c50e 100644 --- a/benchmarks/log-utility.js +++ b/benchmarks/log-utility.js @@ -1,6 +1,8 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later +// Copyright (c) 2015-2023 MariaDB Corporation Ab + 'use strict'; -const pjson = require('../package-lock.json'); const chalk = require('chalk'); const defaultImgJson = { type: 'horizontalBar',