53 lines
1.6 KiB
JavaScript
53 lines
1.6 KiB
JavaScript
var pool = require('./index.js').createPool({ database: 'test', connectionLimit: 100});
|
|
//var pool = require('mysql').createPool({ database: 'test', connectionLimit: 100});
|
|
var count = 0;
|
|
var start = process.hrtime();
|
|
var start1 = process.hrtime();
|
|
var rowsInterval = 10000000;
|
|
//var q = 'select 1';
|
|
var q = 'select id from insert_test limit ? ';
|
|
function bench() {
|
|
//conn.query(q, function(err, rows) {
|
|
//conn.query(q, [ Number(process.argv[3]) ], function(err, rows) {
|
|
pool.getConnection(function(err, conn) {
|
|
debugger;
|
|
//conn.changeUser({ user: 'benchmarkdbuser', password: 'benchmarkdbpass'}, function() { console.log('!!!');
|
|
conn.changeUser({ user: 'root', password: ''}, function() { console.log('!!!');
|
|
|
|
conn.query('select USER()', console.log);
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
conn.execute(q, [ Number(process.argv[3]) ]).on('result', function(row) {
|
|
count++;
|
|
/*
|
|
if (count % rowsInterval == 0) {
|
|
var end = process.hrtime(start);
|
|
var rps = count*1e9/(end[0]*1e9+end[1]);
|
|
var end = process.hrtime(start1);
|
|
var rpslocal = rowsInterval*1e9/(end[0]*1e9+end[1]);
|
|
console.log(count, rps, rpslocal);
|
|
start1 = process.hrtime();
|
|
}
|
|
*/
|
|
}).on('end', function() {
|
|
if (count > 10*rowsInterval) {
|
|
var end = process.hrtime(start1);
|
|
var rpslocal = rowsInterval*10*1e9/(end[0]*1e9+end[1]);
|
|
console.log(count, rpslocal);
|
|
return pool.end();
|
|
}
|
|
conn.release();
|
|
bench();
|
|
});
|
|
});
|
|
}
|
|
|
|
var n = parseInt(process.argv[2], 10);
|
|
for(; n > 0; --n) {
|
|
console.log('starting bench')
|
|
bench();
|
|
}
|