use of org.apache.camel.builder.ExchangeBuilder in project opennms by OpenNMS.
the class JaxbUtilsUnmarshalProcessorTest method testSpeed.
@Test
public void testSpeed() throws Exception {
TestMe test = new TestMe();
test.lets = "lets";
test.make = "make";
test.an = "an";
test.object = "object";
String marshalled = JaxbUtils.marshal(test);
final int numberOfMessages = 10000;
final int warmUp = 4000;
CamelContext m_camel = new DefaultCamelContext(new SimpleRegistry());
JaxbUtilsUnmarshalProcessor processor = new JaxbUtilsUnmarshalProcessor(TestMe.class);
List<Exchange> exchanges = IntStream.range(0, numberOfMessages).mapToObj(i -> {
return new ExchangeBuilder(m_camel).withBody(marshalled).build();
}).collect(Collectors.toList());
int counter = 0;
long begin = 0;
long end = 0;
for (Exchange exchange : exchanges) {
processor.process(exchange);
if (counter++ < warmUp) {
// Warm up
continue;
}
if (begin == 0) {
begin = System.currentTimeMillis();
}
// System.out.println(end = System.currentTimeMillis());
end = System.currentTimeMillis();
}
System.out.println("BEGIN: " + begin);
System.out.println("END: " + end);
System.out.println("TOTAL TIME: " + (end - begin));
System.out.println("RATE: " + ((double) (numberOfMessages - warmUp) / (double) (end - begin)) + "/ms");
}
Aggregations