Comparing version 0.1.3 to 0.2.0
var async = require('async'); | ||
module.exports = function (pool, query, count, concurrency, callback) { | ||
module.exports = function (pool, config, query, callback) { | ||
var tasks = []; | ||
// Push X queries onto the async queue where X is the level of concurrency | ||
for (var i = 0; i < concurrency; i++) { | ||
for (var i = 0; i < config.concurrency; i++) { | ||
tasks.push(function(task_callback) { | ||
// Get a Sphinx connection from the pool | ||
pool.getConnection(function(pool_error, connection) { | ||
if (pool_error) { | ||
task_callback(pool_error); | ||
return task_callback(pool_error); | ||
} | ||
@@ -18,3 +17,3 @@ | ||
if (query_error) { | ||
task_callback(query_error); | ||
return task_callback(query_error); | ||
} | ||
@@ -31,2 +30,3 @@ | ||
// Execute all the tasks (queries) in parallel | ||
async.parallel(tasks, function(error, results) { | ||
@@ -37,6 +37,4 @@ if (error != null) { | ||
count += results.length; | ||
callback(count); | ||
callback(results.length); | ||
}); | ||
}; |
@@ -1,2 +0,2 @@ | ||
module.exports = function (start, count, cli) { | ||
module.exports = function (start, count, config) { | ||
var end = +new Date(); | ||
@@ -11,6 +11,7 @@ var time_taken = (end - start) / 1000; | ||
console.log('-------------------------'); | ||
console.log(' Host: ' + cli.host); | ||
console.log(' Port: ' + cli.port); | ||
console.log(' Connections: ' + cli.connections); | ||
console.log(' Concurrency: ' + cli.concurrency); | ||
console.log(' Host: ' + config.host); | ||
console.log(' Port: ' + config.port); | ||
console.log(' Workers: ' + config.cpus); | ||
console.log(' Connections: ' + config.connections); | ||
console.log(' Concurrency: ' + config.concurrency); | ||
console.log(''); | ||
@@ -17,0 +18,0 @@ |
{ | ||
"name": "sb", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"description": "A simple tool to benchmark a Sphinx search server.", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9378