Skip to content
Browse files

Updates for node 0.5

Fix for # precision for external.js
  • Loading branch information...
1 parent d0a7b4e commit b8b22d0799fb74059dcba95ba5ff7253d41d03a9 @jonjlee jonjlee committed Sep 22, 2011
Showing with 20 additions and 13 deletions.
  1. +2 −0 TODO
  2. +4 −6 examples/test-server.js
  3. +10 −3 lib/reporting/external.js
  4. +2 −1 nodeload.js
  5. +1 −1 package.json
  6. +1 −1 test/loop.test.js
  7. +0 −1 test/monitoring.test.js
View
2 TODO
@@ -24,3 +24,5 @@
- Methods for graphing histograms
- Allow graphs to be overlayed
- Use agents for concurrent connections
+- Label Y axes
+- Add customizable notes section to summary page
View
10 examples/test-server.js
@@ -1,13 +1,11 @@
#!/usr/bin/env node
-var sys = require('sys'),
- http = require('http');
-http.createServer(function (req, res) {
- var maxDelayMs = 10;
- var delay = Math.round(Math.random()*maxDelayMs);
+require('http').createServer(function (req, res) {
+ var maxDelayMs = 500;
+ var delay = Math.round(Math.random()*maxDelayMs) + 1000;
setTimeout(function () {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write(delay+'\n');
res.end();
}, delay);
}).listen(9000);
-sys.puts('Server running at http://127.0.0.1:9000/');
+console.log('Server running at http://127.0.0.1:9000/');
View
13 lib/reporting/external.js
@@ -51,13 +51,20 @@ Returns a standard ChildProcess object.
var graphProcess = exports.graphProcess = function(options) {
var delimiter = options.delimiter || ' +',
columns = options.columns || [],
- fieldRegex = columns.map(function() { return '(.*?)'; }).join(delimiter), // e.g. (.*?) +(.*?) +...
- regex = options.regex || ('^ *' + fieldRegex + ' *$'),
+ fieldRegex = columns.map(function() { return '([0-9.e+-]+)'; }).join(delimiter), // e.g. ([0-9.e+-]*) +([0-9.e+-]*) +...
+ regex = options.regex || ('^ *' + fieldRegex),
splitIdx = columns.indexOf(options.splitBy) + 1;
+ var valuesToNumber = function(o) {
+ for (var i in o) {
+ o[i] = Number(Number(o[i]).toFixed(2));
+ }
+ return o;
+ };
+
var report = REPORT_MANAGER.getReport(options.reportName || 'Monitor'),
graph = report.getChart(options.chartName || options.command),
- format = options.dataFormatter || function(x) { return x; };
+ format = options.dataFormatter || valuesToNumber;
var proc = child_process.spawn('/bin/sh', ['-c', options.command], options.spawnOptions),
lr = new util.LineReader(proc.stdout);
View
3 nodeload.js
@@ -108,7 +108,8 @@ var REPORT_MANAGER=exports.REPORT_MANAGER=new ReportGroup();NODELOAD_CONFIG.on('
var graphProcess;var graphJmx=exports.graphJmx=function(options){var m=module;var jmxstat,found=false;while(m&&!found){jmxstat=path.join(path.dirname(m.filename),'jmxstat/jmxstat.jar');found=path.existsSync(jmxstat);m=m.parent;}
if(!found){throw new Error('jmxstat/jmxstat.jar not found.');}
var regex='\\d{2}:\\d{2}:\\d{2}',columns=[],mbeans=[];for(var mbean in options.mbeans){regex+='\\t([^\\t]*)';columns.push(mbean);mbeans.push(options.mbeans[mbean]);}
-var interval=options.interval||'';return graphProcess({reportName:options.reportName||options.host||'Monitor',chartName:options.chartName||'JMX',command:'java -jar '+jmxstat+' '+options.host+' '+mbeans.join(' ')+' '+interval,columns:columns,regex:regex,dataFormatter:options.dataFormatter});};var graphProcess=exports.graphProcess=function(options){var delimiter=options.delimiter||' +',columns=options.columns||[],fieldRegex=columns.map(function(){return'(.*?)';}).join(delimiter),regex=options.regex||('^ *'+fieldRegex+' *$'),splitIdx=columns.indexOf(options.splitBy)+1;var report=REPORT_MANAGER.getReport(options.reportName||'Monitor'),graph=report.getChart(options.chartName||options.command),format=options.dataFormatter||function(x){return x;};var proc=child_process.spawn('/bin/sh',['-c',options.command],options.spawnOptions),lr=new util.LineReader(proc.stdout);lr.on('data',function(line){var vals=line.match(regex);if(vals){var obj={},prefix='';if(splitIdx>0&&vals[splitIdx]){prefix=vals[splitIdx]+' ';}
+var interval=options.interval||'';return graphProcess({reportName:options.reportName||options.host||'Monitor',chartName:options.chartName||'JMX',command:'java -jar '+jmxstat+' '+options.host+' '+mbeans.join(' ')+' '+interval,columns:columns,regex:regex,dataFormatter:options.dataFormatter});};var graphProcess=exports.graphProcess=function(options){var delimiter=options.delimiter||' +',columns=options.columns||[],fieldRegex=columns.map(function(){return'([0-9.e+-]+)';}).join(delimiter),regex=options.regex||('^ *'+fieldRegex),splitIdx=columns.indexOf(options.splitBy)+1;var valuesToNumber=function(o){for(var i in o){o[i]=Number(Number(o[i]).toFixed(2));}
+return o;};var report=REPORT_MANAGER.getReport(options.reportName||'Monitor'),graph=report.getChart(options.chartName||options.command),format=options.dataFormatter||valuesToNumber;var proc=child_process.spawn('/bin/sh',['-c',options.command],options.spawnOptions),lr=new util.LineReader(proc.stdout);lr.on('data',function(line){var vals=line.match(regex);if(vals){var obj={},prefix='';if(splitIdx>0&&vals[splitIdx]){prefix=vals[splitIdx]+' ';}
for(var i=1;i<vals.length;i++){if(columns[i-1]){obj[prefix+columns[i-1]]=vals[i];}}
graph.put(format(obj));}});return proc;};var BUILD_AS_SINGLE_FILE;if(BUILD_AS_SINGLE_FILE===undefined){var http=require('http');var util=require('./util');var stats=require('./stats');var reporting=require('./reporting');var qputs=util.qputs;var qprint=util.qprint;var EventEmitter=require('events').EventEmitter;var MultiLoop=require('./loop').MultiLoop;var Monitor=require('./monitoring').Monitor;var Report=reporting.Report;var LogFile=stats.LogFile;var NODELOAD_CONFIG=require('./config').NODELOAD_CONFIG;var START=NODELOAD_CONFIG.START;var REPORT_MANAGER=reporting.REPORT_MANAGER;var HTTP_SERVER=require('./http').HTTP_SERVER;}
var TEST_OPTIONS={name:'Debug test',host:'localhost',port:8080,connectionGenerator:undefined,requestGenerator:undefined,requestLoop:undefined,method:'GET',path:'/',requestData:undefined,numUsers:10,loadProfile:undefined,targetRps:Infinity,userProfile:undefined,numRequests:Infinity,timeLimit:120,delay:0,stats:['latency','result-codes'],};var LoadTest,generateConnection,requestGeneratorLoop;var run=exports.run=function(specs){specs=(specs instanceof Array)?specs:util.argarray(arguments);var tests=specs.map(function(spec){spec=util.defaults(spec,TEST_OPTIONS);var generateRequest=function(client){if(spec.requestGenerator){return spec.requestGenerator(client);}
View
2 package.json
@@ -5,7 +5,7 @@
"keywords": ["testing", "load testing", "http"],
"homepage": "https://github.com/benschmaus/nodeload",
"engines": {
- "node": "0.4"
+ "node": "0.5"
},
"contributors": [
"Benjamin Schmaus <benjamin.schmaus@gmail.com>",
View
2 test/loop.test.js
@@ -27,7 +27,7 @@ module.exports = {
assert.ok(Math.abs(duration - 1000) <= 60, '1000 == ' + duration);
});
},
- 'example: use Scheduler to vary execution rate and concurrency': function (beforeExit) {
+ 'example: use profiles to vary execution rate and concurrency': function (beforeExit) {
var i = 0, c = 0, start = new Date(), duration,
l = new MultiLoop({
fun: function(finished) { i++; finished(); },
View
1 test/monitoring.test.js
@@ -164,7 +164,6 @@ module.exports = {
assert.ok(responseBytesSummary);
assert.equal(resultCodesSummary.total, 2);
- assert.ok(resultCodesSummary.rps >= 0);
assert.equal(resultCodesSummary['200'], 2);
assert.equal(headerCodeSummary['text/plain'], 2);

0 comments on commit b8b22d0

Please sign in to comment.
Something went wrong with that request. Please try again.