aboutsummaryrefslogtreecommitdiff
path: root/benchmarks
diff options
context:
space:
mode:
authorZHANG Dapeng <zdapeng@google.com>2018-08-30 11:48:38 -0700
committerGitHub <noreply@github.com>2018-08-30 11:48:38 -0700
commitd7ce74f83d2d83c40e675ce84963b720f6bdaed1 (patch)
tree06d3101c2c90b851d84ad7aa941a594513b7da60 /benchmarks
parent54f76dfeafe8ac9cf908ceb49ab87bd8348d2dd9 (diff)
downloadgrpc-grpc-java-d7ce74f83d2d83c40e675ce84963b720f6bdaed1.tar.gz
benchmarks: fix nano time comparison
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/src/main/java/io/grpc/benchmarks/qps/AsyncClient.java12
-rw-r--r--benchmarks/src/main/java/io/grpc/benchmarks/qps/OpenLoopClient.java2
2 files changed, 5 insertions, 9 deletions
diff --git a/benchmarks/src/main/java/io/grpc/benchmarks/qps/AsyncClient.java b/benchmarks/src/main/java/io/grpc/benchmarks/qps/AsyncClient.java
index 1d12c770d..413fe889c 100644
--- a/benchmarks/src/main/java/io/grpc/benchmarks/qps/AsyncClient.java
+++ b/benchmarks/src/main/java/io/grpc/benchmarks/qps/AsyncClient.java
@@ -48,10 +48,8 @@ import io.grpc.stub.StreamObserver;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CancellationException;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
import org.HdrHistogram.Histogram;
import org.HdrHistogram.HistogramIterationValue;
@@ -179,7 +177,7 @@ public class AsyncClient {
histogram.recordValue((now - lastCall) / 1000);
lastCall = now;
- if (endTime > now) {
+ if (endTime - now > 0) {
stub.unaryCall(request, this);
} else {
future.done();
@@ -236,7 +234,7 @@ public class AsyncClient {
histogram.recordValue((now - lastCall) / 1000);
lastCall = now;
- if (endTime > now) {
+ if (endTime - now > 0) {
requestObserver.onNext(request);
} else {
requestObserver.onCompleted();
@@ -352,7 +350,7 @@ public class AsyncClient {
}
@Override
- public synchronized Histogram get() throws InterruptedException, ExecutionException {
+ public synchronized Histogram get() throws InterruptedException {
while (!isDone() && !isCancelled()) {
wait();
}
@@ -365,9 +363,7 @@ public class AsyncClient {
}
@Override
- public Histogram get(long timeout, TimeUnit unit) throws InterruptedException,
- ExecutionException,
- TimeoutException {
+ public Histogram get(long timeout, TimeUnit unit) {
throw new UnsupportedOperationException();
}
diff --git a/benchmarks/src/main/java/io/grpc/benchmarks/qps/OpenLoopClient.java b/benchmarks/src/main/java/io/grpc/benchmarks/qps/OpenLoopClient.java
index 60c4df813..f366bc344 100644
--- a/benchmarks/src/main/java/io/grpc/benchmarks/qps/OpenLoopClient.java
+++ b/benchmarks/src/main/java/io/grpc/benchmarks/qps/OpenLoopClient.java
@@ -203,7 +203,7 @@ public class OpenLoopClient {
private void waitForRpcsToComplete(int duration) {
long now = System.nanoTime();
long end = now + duration * 1000 * 1000 * 1000;
- while (histogram.getTotalCount() < numRpcs && now < end) {
+ while (histogram.getTotalCount() < numRpcs && end - now > 0) {
now = System.nanoTime();
}
}