diff options
Diffstat (limited to 'test/core/network_benchmarks')
-rw-r--r-- | test/core/network_benchmarks/low_level_ping_pong.c | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/test/core/network_benchmarks/low_level_ping_pong.c b/test/core/network_benchmarks/low_level_ping_pong.c index 0ce4bd4b25..be82a36306 100644 --- a/test/core/network_benchmarks/low_level_ping_pong.c +++ b/test/core/network_benchmarks/low_level_ping_pong.c @@ -84,7 +84,7 @@ static int read_bytes(int fd, char *buf, size_t read_size, int spin) { size_t bytes_read = 0; int err; do { - err = read(fd, buf + bytes_read, read_size - bytes_read); + err = (int)read(fd, buf + bytes_read, read_size - bytes_read); if (err < 0) { if (errno == EINTR) { continue; @@ -96,7 +96,7 @@ static int read_bytes(int fd, char *buf, size_t read_size, int spin) { return -1; } } else { - bytes_read += err; + bytes_read += (size_t)err; } } while (bytes_read < read_size); return 0; @@ -132,13 +132,13 @@ static int poll_read_bytes(int fd, char *buf, size_t read_size, int spin) { GPR_ASSERT(err == 1); GPR_ASSERT(pfd.revents == POLLIN); do { - err = read(fd, buf + bytes_read, read_size - bytes_read); + err = (int)read(fd, buf + bytes_read, read_size - bytes_read); } while (err < 0 && errno == EINTR); if (err < 0 && errno != EAGAIN) { gpr_log(GPR_ERROR, "Read failed: %s", strerror(errno)); return -1; } - bytes_read += err; + bytes_read += (size_t)err; } while (bytes_read < read_size); return 0; } @@ -172,10 +172,11 @@ static int epoll_read_bytes(struct thread_args *args, char *buf, int spin) { GPR_ASSERT(ev.data.fd == args->fds.read_fd); do { do { - err = read(args->fds.read_fd, buf + bytes_read, read_size - bytes_read); + err = (int)read(args->fds.read_fd, buf + bytes_read, + read_size - bytes_read); } while (err < 0 && errno == EINTR); if (errno == EAGAIN) break; - bytes_read += err; + bytes_read += (size_t)err; /* TODO(klempner): This should really be doing an extra call after we are done to ensure we see an EAGAIN */ } while (bytes_read < read_size); @@ -202,8 +203,8 @@ static int blocking_write_bytes(struct thread_args *args, char *buf) { int err; size_t write_size = args->msg_size; do { - err = write(args->fds.write_fd, buf + bytes_written, - write_size - bytes_written); + err = (int)write(args->fds.write_fd, buf + bytes_written, + write_size - bytes_written); if (err < 0) { if (errno == EINTR) { continue; @@ -212,7 +213,7 @@ static int blocking_write_bytes(struct thread_args *args, char *buf) { return -1; } } else { - bytes_written += err; + bytes_written += (size_t)err; } } while (bytes_written < write_size); return 0; @@ -297,7 +298,7 @@ static void print_histogram(gpr_histogram *histogram) { static double now(void) { gpr_timespec tv = gpr_now(GPR_CLOCK_REALTIME); - return 1e9 * tv.tv_sec + tv.tv_nsec; + return 1e9 * (double)tv.tv_sec + tv.tv_nsec; } static void client_thread(thread_args *args) { @@ -387,7 +388,7 @@ static int connect_client(struct sockaddr *addr, int len) { } do { - err = connect(fd, addr, len); + err = (int)connect(fd, addr, (socklen_t)len); } while (err < 0 && errno == EINTR); if (err < 0) { @@ -590,23 +591,23 @@ static int run_all_benchmarks(int msg_size) { int error = 0; size_t i; for (i = 0; i < GPR_ARRAY_SIZE(test_strategies); ++i) { - test_strategy *test_strategy = &test_strategies[i]; + test_strategy *ts = &test_strategies[i]; size_t j; for (j = 0; j < GPR_ARRAY_SIZE(socket_types); ++j) { thread_args *client_args = malloc(sizeof(thread_args)); thread_args *server_args = malloc(sizeof(thread_args)); char *socket_type = socket_types[j]; - client_args->read_bytes = test_strategy->read_strategy; + client_args->read_bytes = ts->read_strategy; client_args->write_bytes = blocking_write_bytes; - client_args->setup = test_strategy->setup; - client_args->msg_size = msg_size; - client_args->strategy_name = test_strategy->name; - server_args->read_bytes = test_strategy->read_strategy; + client_args->setup = ts->setup; + client_args->msg_size = (size_t)msg_size; + client_args->strategy_name = ts->name; + server_args->read_bytes = ts->read_strategy; server_args->write_bytes = blocking_write_bytes; - server_args->setup = test_strategy->setup; - server_args->msg_size = msg_size; - server_args->strategy_name = test_strategy->name; + server_args->setup = ts->setup; + server_args->msg_size = (size_t)msg_size; + server_args->strategy_name = ts->name; error = run_benchmark(socket_type, client_args, server_args); if (error < 0) { return error; @@ -623,7 +624,7 @@ int main(int argc, char **argv) { char *read_strategy = NULL; char *socket_type = NULL; size_t i; - const test_strategy *test_strategy = NULL; + const test_strategy *ts = NULL; int error = 0; gpr_cmdline *cmdline = @@ -657,23 +658,23 @@ int main(int argc, char **argv) { for (i = 0; i < GPR_ARRAY_SIZE(test_strategies); ++i) { if (strcmp(test_strategies[i].name, read_strategy) == 0) { - test_strategy = &test_strategies[i]; + ts = &test_strategies[i]; } } - if (test_strategy == NULL) { + if (ts == NULL) { fprintf(stderr, "Invalid read strategy %s\n", read_strategy); return -1; } - client_args->read_bytes = test_strategy->read_strategy; + client_args->read_bytes = ts->read_strategy; client_args->write_bytes = blocking_write_bytes; - client_args->setup = test_strategy->setup; - client_args->msg_size = msg_size; + client_args->setup = ts->setup; + client_args->msg_size = (size_t)msg_size; client_args->strategy_name = read_strategy; - server_args->read_bytes = test_strategy->read_strategy; + server_args->read_bytes = ts->read_strategy; server_args->write_bytes = blocking_write_bytes; - server_args->setup = test_strategy->setup; - server_args->msg_size = msg_size; + server_args->setup = ts->setup; + server_args->msg_size = (size_t)msg_size; server_args->strategy_name = read_strategy; error = run_benchmark(socket_type, client_args, server_args); |