Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

loadtest

Package Overview
Dependencies
Maintainers
1
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

loadtest - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

2

bin/loadtest.js

@@ -29,3 +29,3 @@ #!/usr/bin/env node

assignArgument('r', args, 'recover', options, true);
assignArgument('agent', args, 'noAgent', options, false);
assignArgument('agent', args, 'agent', options, false);
assignArgument('keepalive', args, 'agentKeepAlive', options, true);

@@ -32,0 +32,0 @@ assignArgument('quite', args, 'quiet', options, true);

@@ -36,1 +36,10 @@

### 2013-09-06: version 0.2.3
* Update sample.js: fix option key for POST body.
Pull request #11 by https://github.com/danieltdt
* Fix maxSeconds option, added test.
Pull request #12 by https://github.com/danieltdt
* Show more complete information: concurrency, agent...
* Clean up for loadtest.run(), should not be used.

@@ -10,2 +10,3 @@ 'use strict';

// requires
var testing = require('testing');
var urlLib = require('url');

@@ -24,6 +25,2 @@ var http = require('http');

// constants
var DEFAULT_OPTIONS = {
noAgent: true,
concurrency: 1
};
var SHOW_INTERVAL_MS = 5000;

@@ -68,3 +65,3 @@

options.headers = {};
if (params.noAgent)
if (!params.agent)
{

@@ -282,2 +279,3 @@ options.agent = false;

var showTimer;
var stopTimeout;

@@ -293,3 +291,3 @@ /**

{
setTimeout(stop, options.maxSeconds * 1000);
stopTimeout = setTimeout(stop, options.maxSeconds * 1000);
}

@@ -358,2 +356,6 @@ showTimer = new timing.HighResolutionTimer(SHOW_INTERVAL_MS, self.latency.showPartial);

}
if (stopTimeout)
{
clearTimeout(stopTimeout);
}
self.running = false;

@@ -364,3 +366,2 @@

});
if (callback)

@@ -374,14 +375,30 @@ {

/**
* Process command line arguments and run
* A load test with max seconds.
*/
exports.run = function(options)
function testMaxSeconds(callback)
{
exports.loadTest(ce.cloneextend(DEFAULT_OPTIONS, options));
};
var options = {
url: 'http://localhost:7357/',
maxSeconds: 0.1,
concurrency: 1,
quiet: true,
};
exports.loadTest(options, callback);
}
// start load test if invoked directly
/**
* Run all tests.
*/
exports.test = function(callback)
{
testing.run({
maxSeconds: testMaxSeconds,
}, callback);
}
// run tests if invoked directly
if (__filename == process.argv[1])
{
exports.run(process.argv.slice(2));
exports.test(testing.show);
}

@@ -39,3 +39,3 @@ 'use strict';

method: 'POST',
payload: {
body: {
hi: 'there',

@@ -42,0 +42,0 @@ },

@@ -185,3 +185,3 @@ 'use strict';

var elapsedSeconds = getElapsed(initialTime) / 1000;
if (options.maxSeconds && elapsedSeconds >= maxSeconds)
if (options.maxSeconds && elapsedSeconds >= options.maxSeconds)
{

@@ -267,3 +267,29 @@ log.debug('Max seconds reached: %s', totalRequests);

log.info('');
log.info('Target URL: %s', options.url);
if (options.maxRequests)
{
log.info('Max requests: %s', options.maxRequests);
}
else if (options.maxSeconds)
{
log.info('Max time (s): %s', options.maxSeconds);
}
log.info('Concurrency level: %s', options.concurrency);
var agent = 'none';
if (options.agent)
{
agent = 'node.js default';
}
else if (options.agentkeepalive)
{
agent = 'keepalive';
}
log.info('Agent: %s', agent);
if (options.requestsPerSecond)
{
log.info('Requests per second: %s', options.requestsPerSecond);
}
log.info('');
log.info('Completed requests: %s', results.totalRequests);
log.info('Total errors: %s', results.totalErrors);
log.info('Total time: %s s', results.totalTimeSeconds);

@@ -285,4 +311,4 @@ log.info('Requests per second: %s', results.rps);

log.info('');
Object.keys(results.errorCodes).forEach(function(errorCode) {
Object.keys(results.errorCodes).forEach(function(errorCode)
{
var padding = ' '.repeat(4 - errorCode.length);

@@ -394,2 +420,3 @@ log.info(' %s%s: %s errors', padding, errorCode, results.errorCodes[errorCode]);

var active = true;
var timer;

@@ -413,3 +440,3 @@ /**

}
setTimeout(delayed, delayMs - diff);
timer = setTimeout(delayed, delayMs - diff);
}

@@ -433,2 +460,7 @@

active = false;
if (timer)
{
clearTimeout(timer);
timer = null;
}
};

@@ -438,3 +470,3 @@

delayed();
setTimeout(delayed, delayMs);
timer = setTimeout(delayed, delayMs);
};

@@ -441,0 +473,0 @@

{
"name": "loadtest",
"version": "0.2.2",
"version": "0.2.3",
"description": "Run load tests for your web application. Mostly ab-compatible interface, with an option to force requests per second. Includes an API for automated load testing.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/alexfernandez/loadtest",

@@ -23,3 +23,3 @@ 'use strict';

var tests = {};
var libs = [ 'prototypes', 'timing', 'sample', 'websocket' ];
var libs = [ 'prototypes', 'timing', 'sample', 'websocket', 'loadtest' ];
libs.forEach(function(lib)

@@ -26,0 +26,0 @@ {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc