diff options
author | murgatroid99 <mlumish@google.com> | 2016-10-18 15:56:44 -0700 |
---|---|---|
committer | murgatroid99 <mlumish@google.com> | 2016-10-18 15:56:44 -0700 |
commit | 3dc67018a0be747917c2d43a72bc072d2b7f2d00 (patch) | |
tree | b08d1a09398c326b2d5f6e06b5982d60876cf9b4 /src/node | |
parent | 697b167ff35a7d09cc96b3bd99744ef23ab0fd0c (diff) |
Fix issues with express benchmark and synchronize package.json with template
Diffstat (limited to 'src/node')
-rw-r--r-- | src/node/performance/benchmark_client_express.js | 8 | ||||
-rw-r--r-- | src/node/performance/benchmark_server_express.js | 8 | ||||
-rw-r--r-- | src/node/performance/worker_service_impl.js | 2 |
3 files changed, 11 insertions, 7 deletions
diff --git a/src/node/performance/benchmark_client_express.js b/src/node/performance/benchmark_client_express.js index 15bc1132d2..675eb5f288 100644 --- a/src/node/performance/benchmark_client_express.js +++ b/src/node/performance/benchmark_client_express.js @@ -92,7 +92,9 @@ function BenchmarkClient(server_targets, channels, histogram_params, this.client_options = []; for (var i = 0; i < channels; i++) { - var new_options = _.assign({host: server_targets[i]}, options); + var host_port; + host_port = server_targets[i % server_targets.length].split(':') + var new_options = _.assign({hostname: host_port[0], port: +host_port[1]}, options); new_options.agent = new protocol.Agent(new_options); this.client_options[i] = new_options; } @@ -172,7 +174,7 @@ BenchmarkClient.prototype.startClosedLoop = function( } } - startAllClients(_.assign(options, self.client_options), + startAllClients(_.map(self.client_options, _.partial(_.assign, options)), outstanding_rpcs_per_channel, makeCall, self); }; @@ -236,7 +238,7 @@ BenchmarkClient.prototype.startPoisson = function( var averageIntervalMs = (1 / offered_load) * 1000; - startAllClients(_.assign(options, self.client_options), + startAllClients(_.map(self.client_options, _.partial(_.assign, options)), outstanding_rpcs_per_channel, function(opts){ var p = PoissonProcess.create(averageIntervalMs, function() { makeCall(opts, p); diff --git a/src/node/performance/benchmark_server_express.js b/src/node/performance/benchmark_server_express.js index 07a559f022..065bcf660b 100644 --- a/src/node/performance/benchmark_server_express.js +++ b/src/node/performance/benchmark_server_express.js @@ -46,15 +46,17 @@ var EventEmitter = require('events'); var util = require('util'); var express = require('express'); +var bodyParser = require('body-parser') function unaryCall(req, res) { - var reqObj = JSON.parse(req.body); + var reqObj = req.body; var payload = {body: '0'.repeat(reqObj.response_size)}; - res.send(JSON.dumps(payload)); + res.json(payload); } function BenchmarkServer(host, port, tls, generic, response_size) { var app = express(); + app.use(bodyParser.json()) app.put('/serviceProto.BenchmarkService.service/unaryCall', unaryCall); this.input_host = host; this.input_port = port; @@ -78,7 +80,7 @@ util.inherits(BenchmarkServer, EventEmitter); BenchmarkServer.prototype.start = function() { var self = this; this.server.listen(this.input_port, this.input_hostname, function() { - this.last_wall_time = process.hrtime(); + self.last_wall_time = process.hrtime(); self.emit('started'); }); }; diff --git a/src/node/performance/worker_service_impl.js b/src/node/performance/worker_service_impl.js index 73dcb7afad..3f317f6429 100644 --- a/src/node/performance/worker_service_impl.js +++ b/src/node/performance/worker_service_impl.js @@ -140,7 +140,6 @@ module.exports = function WorkerServiceImpl(benchmark_impl, server) { console.log('ServerConfig %j', request.setup); server = new BenchmarkServer('[::]', request.setup.port, request.setup.security_params); - server.start(); server.on('started', function() { stats = server.mark(); call.write({ @@ -148,6 +147,7 @@ module.exports = function WorkerServiceImpl(benchmark_impl, server) { port: server.getPort() }); }); + server.start(); break; case 'mark': if (server) { |