This repository has been archived on 2018-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
node-task/node_modules/mysql2/benchmarks/test-benchmark-select-1.js

33 lines
941 B
JavaScript

var assert = require('assert');
var createConnection = require('../common').createConnection;
(function(cb) {
var db = createConnection();
var left = 10000;
var start = Date.now();
var prev1000 = start;
function bench()
{
db.query('select 1').on('end', function(err, res) {
left--;
if (left % 1000 === 0)
{
var curTime = Date.now();
var last1000time = curTime - prev1000;
prev1000 = curTime;
console.error( (1000000/last1000time) + ' req/sec' );
}
if (left > 0)
bench();
else {
console.error( 10000000/(Date.now() - start) + ' req/sec (average 10000 reqs)');
db.end();
if (cb) cb();
}
});
}
bench();
})();