Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ install:
test:
npm test

bench:
node ./bench.js

# target: lint, Lints every JavaScript file in the project that are staged to be comitted.
lint:
./scripts/lint-staged.sh
Expand Down
63 changes: 63 additions & 0 deletions bench.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
var graylog = require('./graylog');
var fs = require('fs');
var servers = [
{ 'host': '127.0.0.1', 'port': 12201 }
];

var client = new graylog.graylog({
servers: servers,
facility: 'node-graylog benchmark'
});


console.log('Deflate:', client.deflate);
console.log('');

console.time('small message');

var i = 0;
var count = 20000;
var small = 'h'.repeat(2500);
var big = 'h'.repeat(25000);
var bigRandom = require('crypto').randomBytes(20000).toString('base64');


function log(str, label, i, n, cb) {
if (i === 0) {
console.time(label + ' x' + n);
}

if (i === n) {
console.timeEnd(label + ' x' + n);
cb();
} else {
client.log('test', str);
setImmediate(log, str, label, i + 1, n, cb);
}
}

function testSmall(cb) {
log(small, 'small', 0, 20000, cb);
}

function testBig(cb) {
log(big, 'big', 0, 10000, cb);
}

function testBigAndRandom(cb) {
log(bigRandom, 'bigAndRandom', 0, 10000, cb);
}

function close() {
client.close(function () {
console.log('');
console.log('Insertion complete. Please check', 'http://' + servers[0].host + ':3000', 'and verify that insertion was successfull');
});
}

testSmall(function () {
testBig(function () {
testBigAndRandom(close);
});
});

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
],
"devDependencies": {
"jshint": "0.9.1"
"jshint": "2.9.2"
},
"engines": {
"node": ">=0.6.11"
Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ try {
facility: 'Test logger / Node.JS Test Script',
deflate: 'not an option'
});
throw new Error('should not get here')
throw new Error('should not get here');
} catch (err) {
assert(
err.message === 'deflate must be one of "optimal", "always", or "never". was "not an option"',
Expand Down