-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbenchmark.js
43 lines (34 loc) · 1.13 KB
/
benchmark.js
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
const syncmysql = require("./conf/mysqlsync");
const mysqlperso = require("./conf/mysql");
let dt = Date.now();
console.log("Test mysql-sync");
syncmysql.query("SELECT * FROM users");
console.log((Date.now() - dt) + " ms");
dt = Date.now();
console.log("Test mysql-perso");
let va = mysqlperso.query("SELECT * FROM users");
console.log((Date.now() - dt) + " ms");
let asyncTest = async () => {
var MySql = require('mysql');
const util = require("util");
var connection = MySql.createConnection({
host: 'localhost',
user: 'discord_bot_rpg',
password: 'sdobFWDViY5tgGYe',
database: 'discord_bot_rpg',
charset: "utf8mb4_unicode_ci"
});
var query = util.promisify(connection.query).bind(connection);
let connMaker = {
connection: connection,
query: async (sql, arr = []) => {
const result = await query(sql, arr);
return JSON.parse(JSON.stringify(result));
}
}
let dt2 = Date.now();
console.log("Test async mysql");
await connMaker.query("SELECT * FROM users");
console.log((Date.now() - dt2) + " ms");
}
asyncTest();