Skip to content

Commit

Permalink
fixup! bench: add simple benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
nechaido committed Jul 27, 2017
1 parent f017915 commit 2521110
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 0 additions & 1 deletion benchmark/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const {
size: argumentSize,
} = args;


const server = cp.fork(
path.join(__dirname, 'server'),
[workersAmount * connectionsPerWorker],
Expand Down
5 changes: 4 additions & 1 deletion benchmark/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
'use strict';

const os = require('os');
const path = require('path');

const jstp = require('..');

const maxConnections = +process.argv[2];
Expand All @@ -15,7 +18,7 @@ const app = new jstp.Application('app', {
const server = jstp.net.createServer([app]);
server.maxConnections = maxConnections;

const socket = '/tmp/jstp_benchmark_ipc';
const socket = path.resolve(os.tmpdir(), 'jstp_benchmark_ipc');

const terminate = () => {
server.close();
Expand Down
7 changes: 3 additions & 4 deletions benchmark/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ process.on('message', ([type, ...payload]) => {
function connect(socket) {
let connected = 0;
const createConnection = (index) => {
jstp.net.connectAndInspect('app', null, ['iface'], socket,
(error, conn) => {
jstp.net.connectAndInspect(
'app', null, ['iface'], socket, (error, conn) => {
connected++;

if (error) {
Expand All @@ -42,7 +42,6 @@ function connect(socket) {
for (let i = 0; i < connections.length; i++) {
createConnection(i);
}

}

function start(requests) {
Expand All @@ -51,7 +50,7 @@ function start(requests) {
responseTimesHR[i] = new Array(requests);
}
let responses = 0;
let startTimeHR = new Array(2);
let startTimeHR = null;

const sendRequest = (connectionIndex, requestIndex) => {
const timeOfStart = process.hrtime();
Expand Down

0 comments on commit 2521110

Please sign in to comment.