Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.arrow.flight.perf;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
Expand Down Expand Up @@ -78,15 +79,18 @@ public static void main(String[] args) throws Exception {

@Test
public void throughput() throws Exception {
for (int i = 0; i < 10; i++) {
final int numRuns = 10;
ListeningExecutorService pool = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(4));
double [] throughPuts = new double[numRuns];

for (int i = 0; i < numRuns; i++) {
try (
final BufferAllocator a = new RootAllocator(Long.MAX_VALUE);
final PerformanceTestServer server =
FlightTestUtil.getStartedServer((location) -> new PerformanceTestServer(a, location));
final FlightClient client = FlightClient.builder(a, server.getLocation()).build();
) {
final FlightInfo info = client.getInfo(getPerfFlightDescriptor(50_000_000L, 4095, 2));
ListeningExecutorService pool = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(4));
List<ListenableFuture<Result>> results = info.getEndpoints()
.stream()
.map(t -> new Consumer(client, t.getTicket()))
Expand All @@ -102,16 +106,25 @@ public void throughput() throws Exception {
}).get();

double seconds = r.nanos * 1.0d / 1000 / 1000 / 1000;
throughPuts[i] = (r.bytes * 1.0d / 1024 / 1024) / seconds;
System.out.println(String.format(
"Transferred %d records totaling %s bytes at %f MiB/s. %f record/s. %f batch/s.",
r.rows,
r.bytes,
(r.bytes * 1.0d / 1024 / 1024) / seconds,
throughPuts[i],
(r.rows * 1.0d) / seconds,
(r.batches * 1.0d) / seconds
));
}
}
pool.shutdown();

System.out.println("Summary: ");
double average = Arrays.stream(throughPuts).sum() / numRuns;
double sqrSum = Arrays.stream(throughPuts).map(val -> val - average).map(val -> val * val).sum();
double stddev = Math.sqrt(sqrSum / numRuns);
System.out.println(String.format("Average throughput: %f MiB/s, standard deviation: %f MiB/s",
average, stddev));
}

private final class Consumer implements Callable<Result> {
Expand Down