mirror of https://github.com/grpc/grpc-node.git
Node benchmarks: allow arbitrary message size, add CPU usage stats
This commit is contained in:
parent
5706b9c014
commit
12fdb4192a
|
|
@ -88,7 +88,10 @@ function timeDiffToNanos(time_diff) {
|
||||||
*/
|
*/
|
||||||
function BenchmarkClient(server_targets, channels, histogram_params,
|
function BenchmarkClient(server_targets, channels, histogram_params,
|
||||||
security_params) {
|
security_params) {
|
||||||
var options = {};
|
var options = {
|
||||||
|
"grpc.max_receive_message_length": -1,
|
||||||
|
"grpc.max_send_message_length": -1
|
||||||
|
};
|
||||||
var creds;
|
var creds;
|
||||||
if (security_params) {
|
if (security_params) {
|
||||||
var ca_path;
|
var ca_path;
|
||||||
|
|
@ -180,6 +183,8 @@ BenchmarkClient.prototype.startClosedLoop = function(
|
||||||
|
|
||||||
self.last_wall_time = process.hrtime();
|
self.last_wall_time = process.hrtime();
|
||||||
|
|
||||||
|
self.last_usage = process.cpuUsage();
|
||||||
|
|
||||||
var makeCall;
|
var makeCall;
|
||||||
|
|
||||||
var argument;
|
var argument;
|
||||||
|
|
@ -270,6 +275,8 @@ BenchmarkClient.prototype.startPoisson = function(
|
||||||
|
|
||||||
self.last_wall_time = process.hrtime();
|
self.last_wall_time = process.hrtime();
|
||||||
|
|
||||||
|
self.last_usage = process.cpuUsage();
|
||||||
|
|
||||||
var makeCall;
|
var makeCall;
|
||||||
|
|
||||||
var argument;
|
var argument;
|
||||||
|
|
@ -354,9 +361,11 @@ BenchmarkClient.prototype.startPoisson = function(
|
||||||
*/
|
*/
|
||||||
BenchmarkClient.prototype.mark = function(reset) {
|
BenchmarkClient.prototype.mark = function(reset) {
|
||||||
var wall_time_diff = process.hrtime(this.last_wall_time);
|
var wall_time_diff = process.hrtime(this.last_wall_time);
|
||||||
|
var usage_diff = process.cpuUsage(this.last_usage);
|
||||||
var histogram = this.histogram;
|
var histogram = this.histogram;
|
||||||
if (reset) {
|
if (reset) {
|
||||||
this.last_wall_time = process.hrtime();
|
this.last_wall_time = process.hrtime();
|
||||||
|
this.last_usage = process.cpuUsage();
|
||||||
this.histogram = new Histogram(histogram.resolution,
|
this.histogram = new Histogram(histogram.resolution,
|
||||||
histogram.max_possible);
|
histogram.max_possible);
|
||||||
}
|
}
|
||||||
|
|
@ -371,9 +380,8 @@ BenchmarkClient.prototype.mark = function(reset) {
|
||||||
count: histogram.getCount()
|
count: histogram.getCount()
|
||||||
},
|
},
|
||||||
time_elapsed: wall_time_diff[0] + wall_time_diff[1] / 1e9,
|
time_elapsed: wall_time_diff[0] + wall_time_diff[1] / 1e9,
|
||||||
// Not sure how to measure these values
|
time_user: usage_diff.user / 1000000,
|
||||||
time_user: 0,
|
time_system: usage_diff.system / 1000000
|
||||||
time_system: 0
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,6 @@ function BenchmarkClient(server_targets, channels, histogram_params,
|
||||||
var host_port;
|
var host_port;
|
||||||
host_port = server_targets[i % server_targets.length].split(':');
|
host_port = server_targets[i % server_targets.length].split(':');
|
||||||
var new_options = _.assign({hostname: host_port[0], port: +host_port[1]}, options);
|
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;
|
this.client_options[i] = new_options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -137,6 +136,7 @@ BenchmarkClient.prototype.startClosedLoop = function(
|
||||||
}
|
}
|
||||||
|
|
||||||
self.last_wall_time = process.hrtime();
|
self.last_wall_time = process.hrtime();
|
||||||
|
self.last_usage = process.cpuUsage();
|
||||||
|
|
||||||
var argument = {
|
var argument = {
|
||||||
response_size: resp_size,
|
response_size: resp_size,
|
||||||
|
|
@ -207,6 +207,7 @@ BenchmarkClient.prototype.startPoisson = function(
|
||||||
}
|
}
|
||||||
|
|
||||||
self.last_wall_time = process.hrtime();
|
self.last_wall_time = process.hrtime();
|
||||||
|
self.last_usage = process.cpuUsage();
|
||||||
|
|
||||||
var argument = {
|
var argument = {
|
||||||
response_size: resp_size,
|
response_size: resp_size,
|
||||||
|
|
@ -264,9 +265,11 @@ BenchmarkClient.prototype.startPoisson = function(
|
||||||
*/
|
*/
|
||||||
BenchmarkClient.prototype.mark = function(reset) {
|
BenchmarkClient.prototype.mark = function(reset) {
|
||||||
var wall_time_diff = process.hrtime(this.last_wall_time);
|
var wall_time_diff = process.hrtime(this.last_wall_time);
|
||||||
|
var usage_diff = process.cpuUsage(this.last_usage);
|
||||||
var histogram = this.histogram;
|
var histogram = this.histogram;
|
||||||
if (reset) {
|
if (reset) {
|
||||||
this.last_wall_time = process.hrtime();
|
this.last_wall_time = process.hrtime();
|
||||||
|
this.last_usage = process.cpuUsage();
|
||||||
this.histogram = new Histogram(histogram.resolution,
|
this.histogram = new Histogram(histogram.resolution,
|
||||||
histogram.max_possible);
|
histogram.max_possible);
|
||||||
}
|
}
|
||||||
|
|
@ -281,9 +284,8 @@ BenchmarkClient.prototype.mark = function(reset) {
|
||||||
count: histogram.getCount()
|
count: histogram.getCount()
|
||||||
},
|
},
|
||||||
time_elapsed: wall_time_diff[0] + wall_time_diff[1] / 1e9,
|
time_elapsed: wall_time_diff[0] + wall_time_diff[1] / 1e9,
|
||||||
// Not sure how to measure these values
|
time_user: usage_diff.user / 1000000,
|
||||||
time_user: 0,
|
time_system: usage_diff.system / 1000000
|
||||||
time_system: 0
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,12 @@ function BenchmarkServer(host, port, tls, generic, response_size) {
|
||||||
server_creds = grpc.ServerCredentials.createInsecure();
|
server_creds = grpc.ServerCredentials.createInsecure();
|
||||||
}
|
}
|
||||||
|
|
||||||
var server = new grpc.Server();
|
var options = {
|
||||||
|
"grpc.max_receive_message_length": -1,
|
||||||
|
"grpc.max_send_message_length": -1
|
||||||
|
};
|
||||||
|
|
||||||
|
var server = new grpc.Server(options);
|
||||||
this.port = server.bind(host + ':' + port, server_creds);
|
this.port = server.bind(host + ':' + port, server_creds);
|
||||||
if (generic) {
|
if (generic) {
|
||||||
server.addService(genericService, {
|
server.addService(genericService, {
|
||||||
|
|
@ -156,6 +161,7 @@ util.inherits(BenchmarkServer, EventEmitter);
|
||||||
BenchmarkServer.prototype.start = function() {
|
BenchmarkServer.prototype.start = function() {
|
||||||
this.server.start();
|
this.server.start();
|
||||||
this.last_wall_time = process.hrtime();
|
this.last_wall_time = process.hrtime();
|
||||||
|
this.last_usage = process.cpuUsage();
|
||||||
this.emit('started');
|
this.emit('started');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -175,14 +181,15 @@ BenchmarkServer.prototype.getPort = function() {
|
||||||
*/
|
*/
|
||||||
BenchmarkServer.prototype.mark = function(reset) {
|
BenchmarkServer.prototype.mark = function(reset) {
|
||||||
var wall_time_diff = process.hrtime(this.last_wall_time);
|
var wall_time_diff = process.hrtime(this.last_wall_time);
|
||||||
|
var usage_diff = process.cpuUsage(this.last_usage);
|
||||||
if (reset) {
|
if (reset) {
|
||||||
this.last_wall_time = process.hrtime();
|
this.last_wall_time = process.hrtime();
|
||||||
|
this.last_usage = process.cpuUsage();
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
time_elapsed: wall_time_diff[0] + wall_time_diff[1] / 1e9,
|
time_elapsed: wall_time_diff[0] + wall_time_diff[1] / 1e9,
|
||||||
// Not sure how to measure these values
|
time_user: usage_diff.user / 1000000,
|
||||||
time_user: 0,
|
time_system: usage_diff.system / 1000000
|
||||||
time_system: 0
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,7 @@ BenchmarkServer.prototype.start = function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.server.listen(this.input_port, this.input_hostname, function() {
|
this.server.listen(this.input_port, this.input_hostname, function() {
|
||||||
self.last_wall_time = process.hrtime();
|
self.last_wall_time = process.hrtime();
|
||||||
|
self.last_usage = process.cpuUsage();
|
||||||
self.emit('started');
|
self.emit('started');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -91,14 +92,15 @@ BenchmarkServer.prototype.getPort = function() {
|
||||||
|
|
||||||
BenchmarkServer.prototype.mark = function(reset) {
|
BenchmarkServer.prototype.mark = function(reset) {
|
||||||
var wall_time_diff = process.hrtime(this.last_wall_time);
|
var wall_time_diff = process.hrtime(this.last_wall_time);
|
||||||
|
var usage_diff = process.cpuUsage(this.last_usage);
|
||||||
if (reset) {
|
if (reset) {
|
||||||
this.last_wall_time = process.hrtime();
|
this.last_wall_time = process.hrtime();
|
||||||
|
this.last_usage = process.cpuUsage();
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
time_elapsed: wall_time_diff[0] + wall_time_diff[1] / 1e9,
|
time_elapsed: wall_time_diff[0] + wall_time_diff[1] / 1e9,
|
||||||
// Not sure how to measure these values
|
time_user: usage_diff.user / 1000000,
|
||||||
time_user: 0,
|
time_system: usage_diff.system / 1000000
|
||||||
time_system: 0
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue