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,
|
||||
security_params) {
|
||||
var options = {};
|
||||
var options = {
|
||||
"grpc.max_receive_message_length": -1,
|
||||
"grpc.max_send_message_length": -1
|
||||
};
|
||||
var creds;
|
||||
if (security_params) {
|
||||
var ca_path;
|
||||
|
|
@ -180,6 +183,8 @@ BenchmarkClient.prototype.startClosedLoop = function(
|
|||
|
||||
self.last_wall_time = process.hrtime();
|
||||
|
||||
self.last_usage = process.cpuUsage();
|
||||
|
||||
var makeCall;
|
||||
|
||||
var argument;
|
||||
|
|
@ -270,6 +275,8 @@ BenchmarkClient.prototype.startPoisson = function(
|
|||
|
||||
self.last_wall_time = process.hrtime();
|
||||
|
||||
self.last_usage = process.cpuUsage();
|
||||
|
||||
var makeCall;
|
||||
|
||||
var argument;
|
||||
|
|
@ -354,9 +361,11 @@ BenchmarkClient.prototype.startPoisson = function(
|
|||
*/
|
||||
BenchmarkClient.prototype.mark = function(reset) {
|
||||
var wall_time_diff = process.hrtime(this.last_wall_time);
|
||||
var usage_diff = process.cpuUsage(this.last_usage);
|
||||
var histogram = this.histogram;
|
||||
if (reset) {
|
||||
this.last_wall_time = process.hrtime();
|
||||
this.last_usage = process.cpuUsage();
|
||||
this.histogram = new Histogram(histogram.resolution,
|
||||
histogram.max_possible);
|
||||
}
|
||||
|
|
@ -371,9 +380,8 @@ BenchmarkClient.prototype.mark = function(reset) {
|
|||
count: histogram.getCount()
|
||||
},
|
||||
time_elapsed: wall_time_diff[0] + wall_time_diff[1] / 1e9,
|
||||
// Not sure how to measure these values
|
||||
time_user: 0,
|
||||
time_system: 0
|
||||
time_user: usage_diff.user / 1000000,
|
||||
time_system: usage_diff.system / 1000000
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,6 @@ function BenchmarkClient(server_targets, channels, histogram_params,
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
@ -137,6 +136,7 @@ BenchmarkClient.prototype.startClosedLoop = function(
|
|||
}
|
||||
|
||||
self.last_wall_time = process.hrtime();
|
||||
self.last_usage = process.cpuUsage();
|
||||
|
||||
var argument = {
|
||||
response_size: resp_size,
|
||||
|
|
@ -207,6 +207,7 @@ BenchmarkClient.prototype.startPoisson = function(
|
|||
}
|
||||
|
||||
self.last_wall_time = process.hrtime();
|
||||
self.last_usage = process.cpuUsage();
|
||||
|
||||
var argument = {
|
||||
response_size: resp_size,
|
||||
|
|
@ -264,9 +265,11 @@ BenchmarkClient.prototype.startPoisson = function(
|
|||
*/
|
||||
BenchmarkClient.prototype.mark = function(reset) {
|
||||
var wall_time_diff = process.hrtime(this.last_wall_time);
|
||||
var usage_diff = process.cpuUsage(this.last_usage);
|
||||
var histogram = this.histogram;
|
||||
if (reset) {
|
||||
this.last_wall_time = process.hrtime();
|
||||
this.last_usage = process.cpuUsage();
|
||||
this.histogram = new Histogram(histogram.resolution,
|
||||
histogram.max_possible);
|
||||
}
|
||||
|
|
@ -281,9 +284,8 @@ BenchmarkClient.prototype.mark = function(reset) {
|
|||
count: histogram.getCount()
|
||||
},
|
||||
time_elapsed: wall_time_diff[0] + wall_time_diff[1] / 1e9,
|
||||
// Not sure how to measure these values
|
||||
time_user: 0,
|
||||
time_system: 0
|
||||
time_user: usage_diff.user / 1000000,
|
||||
time_system: usage_diff.system / 1000000
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -132,7 +132,12 @@ function BenchmarkServer(host, port, tls, generic, response_size) {
|
|||
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);
|
||||
if (generic) {
|
||||
server.addService(genericService, {
|
||||
|
|
@ -156,6 +161,7 @@ util.inherits(BenchmarkServer, EventEmitter);
|
|||
BenchmarkServer.prototype.start = function() {
|
||||
this.server.start();
|
||||
this.last_wall_time = process.hrtime();
|
||||
this.last_usage = process.cpuUsage();
|
||||
this.emit('started');
|
||||
};
|
||||
|
||||
|
|
@ -175,14 +181,15 @@ BenchmarkServer.prototype.getPort = function() {
|
|||
*/
|
||||
BenchmarkServer.prototype.mark = function(reset) {
|
||||
var wall_time_diff = process.hrtime(this.last_wall_time);
|
||||
var usage_diff = process.cpuUsage(this.last_usage);
|
||||
if (reset) {
|
||||
this.last_wall_time = process.hrtime();
|
||||
this.last_usage = process.cpuUsage();
|
||||
}
|
||||
return {
|
||||
time_elapsed: wall_time_diff[0] + wall_time_diff[1] / 1e9,
|
||||
// Not sure how to measure these values
|
||||
time_user: 0,
|
||||
time_system: 0
|
||||
time_user: usage_diff.user / 1000000,
|
||||
time_system: usage_diff.system / 1000000
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ BenchmarkServer.prototype.start = function() {
|
|||
var self = this;
|
||||
this.server.listen(this.input_port, this.input_hostname, function() {
|
||||
self.last_wall_time = process.hrtime();
|
||||
self.last_usage = process.cpuUsage();
|
||||
self.emit('started');
|
||||
});
|
||||
};
|
||||
|
|
@ -91,14 +92,15 @@ BenchmarkServer.prototype.getPort = function() {
|
|||
|
||||
BenchmarkServer.prototype.mark = function(reset) {
|
||||
var wall_time_diff = process.hrtime(this.last_wall_time);
|
||||
var usage_diff = process.cpuUsage(this.last_usage);
|
||||
if (reset) {
|
||||
this.last_wall_time = process.hrtime();
|
||||
this.last_usage = process.cpuUsage();
|
||||
}
|
||||
return {
|
||||
time_elapsed: wall_time_diff[0] + wall_time_diff[1] / 1e9,
|
||||
// Not sure how to measure these values
|
||||
time_user: 0,
|
||||
time_system: 0
|
||||
time_user: usage_diff.user / 1000000,
|
||||
time_system: usage_diff.system / 1000000
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue