Skip to content

Commit

Permalink
[misc] benchmark improvement and update to recent version of mysql co…
Browse files Browse the repository at this point in the history
…mpatible drivers
  • Loading branch information
rusher committed Jul 23, 2021
1 parent 2b91919 commit 5f68898
Show file tree
Hide file tree
Showing 27 changed files with 462 additions and 765 deletions.
25 changes: 17 additions & 8 deletions README.md
Expand Up @@ -68,20 +68,29 @@ For more information, see the [Batch](/documentation/batch.md) documentation.

MariaDB provides benchmarks comparing the Connector with popular Node.js MySQL clients, including:

* [`promise-mysql`](https://www.npmjs.com/package/promise-mysql) version 4.0.4 + [`mysql`](https://www.npmjs.com/package/mysql) version 2.17.1
* [`mysql2`](https://www.npmjs.com/package/mysql2) version 1.6.5
* [`promise-mysql`](https://www.npmjs.com/package/promise-mysql) version 5.0.4 + [`mysql`](https://www.npmjs.com/package/mysql) version 2.18.1
* [`mysql2`](https://www.npmjs.com/package/mysql2) version 2.2.5


#### query

```
promise-mysql : 646 ops/sec ±2.20%
mysql2 : 746 ops/sec ±2.35%
mariadb : 961 ops/sec ±2.82%
select * from mysql.user - mysql x 1,442 ops/sec ±0.38%
select * from mysql.user - mysql2 x 1,484 ops/sec ±0.60%
select * from mysql.user - mariadb x 1,595 ops/sec ±0.38%
```

query: **SELECT < all mysql fields >, 1 FROM mysql.user LIMIT 1**
<img src="https://quickchart.io/chart/render/zm-e2bd7f00-c7ca-4412-84e5-5284055056b5?data1=1442&data2=1484&data3=1595&title=select%20one%20mysql.user%0A%20%5B%20sql%3A%20select%20*%20from%20mysql.user%20LIMIT%201%20%5D" width="500" height="160"/>

#### execute

<img src="./documentation/misc/bench.png" width="559" height="209"/>
```
select * from mysql.user using execute - mysql2 x 2,257 ops/sec ±0.84%
select * from mysql.user using execute - mariadb x 2,651 ops/sec ±0.59%
```

For more information, see the [Benchmarks](/documentation/benchmarks.md) page.
<img src="https://quickchart.io/chart?devicePixelRatio=1.0&h=140&w=520&c=%7B%22type%22%3A%22horizontalBar%22%2C%22data%22%3A%7B%22datasets%22%3A%5B%7B%22label%22%3A%22mysql2%202.2.5%22%2C%22backgroundColor%22%3A%22%234285f4%22%2C%22data%22%3A%5B2257%5D%7D%2C%7B%22label%22%3A%22mariadb%203.0.1%22%2C%22backgroundColor%22%3A%22%23ff9900%22%2C%22data%22%3A%5B2651%5D%7D%5D%7D%2C%22options%22%3A%7B%22plugins%22%3A%7B%22datalabels%22%3A%7B%22anchor%22%3A%22end%22%2C%22align%22%3A%22start%22%2C%22color%22%3A%22%23fff%22%2C%22font%22%3A%7B%22weight%22%3A%22bold%22%7D%7D%7D%2C%22elements%22%3A%7B%22rectangle%22%3A%7B%22borderWidth%22%3A0%7D%7D%2C%22responsive%22%3Atrue%2C%22legend%22%3A%7B%22position%22%3A%22right%22%7D%2C%22title%22%3A%7B%22display%22%3Atrue%2C%22text%22%3A%22select%20one%20mysql.user%20using%20execute%5Cn%20%5B%20sql%3A%20select%20*%20from%20mysql.user%20LIMIT%201%20%5D%22%7D%2C%22scales%22%3A%7B%22xAxes%22%3A%5B%7B%22display%22%3Atrue%2C%22scaleLabel%22%3A%7B%22display%22%3Atrue%2C%22labelString%22%3A%22operations%20per%20second%22%7D%2C%22ticks%22%3A%7B%22beginAtZero%22%3Atrue%7D%7D%5D%7D%7D%7D" width="500" height="140"/>
For more information, see the [Benchmarks](./documentation/benchmarks.md) page.

## Quick Start

Expand Down
4 changes: 2 additions & 2 deletions benchmarks/benchmarkOne.js
Expand Up @@ -7,10 +7,10 @@ let bench;
const launchBenchs = function (path) {
bench = new Bench();

const test = 'bench_promise_select_param.js';
const test = 'do.js';
const m = require(path + '/' + test);
bench.initFcts.push([m.initFct, m.promise]);
bench.add(m.title, m.displaySql, m.benchFct, m.onComplete, m.promise, m.pool, m.requireExecute); //, bench.CONN.MYSQL);
bench.add(m.title, m.displaySql, m.benchFct, m.onComplete, m.pool, m.requireExecute); //, bench.CONN.MYSQL);

bench.suiteReady();
};
Expand Down
10 changes: 1 addition & 9 deletions benchmarks/benchmarks.js
Expand Up @@ -14,15 +14,7 @@ const launchBenchs = function (path) {
console.log('benchmark: ./benchs/' + list[i]);
const m = require('./benchs/' + list[i]);
bench.initFcts.push([m.initFct, m.promise]);
bench.add(
m.title,
m.displaySql,
m.benchFct,
m.onComplete,
m.promise,
m.pool,
m.requireExecute
);
bench.add(m.title, m.displaySql, m.benchFct, m.onComplete, m.pool, m.requireExecute);
}
bench.suiteReady();
});
Expand Down
13 changes: 0 additions & 13 deletions benchmarks/benchs/bench_do.js

This file was deleted.

12 changes: 0 additions & 12 deletions benchmarks/benchs/bench_promise_select_collation.js

This file was deleted.

9 changes: 0 additions & 9 deletions benchmarks/benchs/bench_promise_select_one_user.js

This file was deleted.

10 changes: 0 additions & 10 deletions benchmarks/benchs/bench_promise_select_one_user_pool.js

This file was deleted.

68 changes: 0 additions & 68 deletions benchmarks/benchs/bench_promise_select_one_user_random.js

This file was deleted.

16 changes: 0 additions & 16 deletions benchmarks/benchs/bench_promise_select_param.js

This file was deleted.

18 changes: 0 additions & 18 deletions benchmarks/benchs/bench_promise_select_random_param_pool.js

This file was deleted.

61 changes: 0 additions & 61 deletions benchmarks/benchs/bench_select_one_user.js

This file was deleted.

65 changes: 0 additions & 65 deletions benchmarks/benchs/bench_select_one_user_random.js

This file was deleted.

15 changes: 0 additions & 15 deletions benchmarks/benchs/bench_select_param.js

This file was deleted.

@@ -1,15 +1,14 @@
const assert = require('assert');

module.exports.title = 'do ? using promise';
module.exports.title = 'do <random number>';
module.exports.displaySql = 'do ?';
module.exports.promise = true;
module.exports.benchFct = function (conn, deferred) {
conn
.query('do ?', ['' + Math.floor(Math.random() * 50000000)])
.query('do ?', [Math.floor(Math.random() * 50000000)])
.then((rows) => {
// let val = Array.isArray(rows) ? rows[0] : rows;
// assert.equal(1, val.info ? val.info.affectedRows : val.affectedRows);
deferred.resolve();
deferred();
})
.catch((err) => {
throw err;
Expand Down

0 comments on commit 5f68898

Please sign in to comment.