use of org.apache.gobblin.writer.test.GobblinTestEventBusWriter in project incubator-gobblin by apache.
the class PerformanceTest method testWriterThroughput.
/**
* Test the throughput of the writer used on {@link #testGobblinThroughput()} to prove it is not a bottleneck.
*/
public static void testWriterThroughput() throws Exception {
EventBus eventBus = new EventBus();
EventHandler eventHandler = new EventHandler();
eventBus.register(eventHandler);
GobblinTestEventBusWriter writer = new GobblinTestEventBusWriter(eventBus, GobblinTestEventBusWriter.Mode.COUNTING);
long records = 0;
long endAt = System.currentTimeMillis() + 10000;
long startTime = System.nanoTime();
for (records = 0; records < 10000000 && System.currentTimeMillis() < endAt; records++) {
writer.write(records);
}
long elapsedMillis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime);
writer.commit();
Assert.assertEquals(eventHandler.runSummaries.get(0).getRecordsWritten(), records);
System.out.println(String.format("Writer consumed %d records in %d millis, qps: %f", records, elapsedMillis, (double) records * 1000 / elapsedMillis));
}
Aggregations