#![feature(test)] extern crate test; extern crate kafka_json_processor_core; use test::Bencher; use kafka_json_processor_core::formatters::xml::pretty_xml; const XML_LOG: &str = r##"[INFO] This is a sample log message. We've got a new request, and we want it pretty printed. Body: Belgian Waffles $5.95Two of our famous Belgian Waffles with plenty of real maple syrup650Strawberry Belgian Waffles$7.95Light Belgian waffles covered with strawberries and whipped cream900Berry-Berry Belgian Waffles$8.95Light Belgian waffles covered with an assortment of fresh berries and whipped cream900French Toast$4.50Thick slices made from our homemade sourdough bread600Homestyle Breakfast$6.95Two eggs, bacon or sausage, toast, and our ever-popular hash browns950"##; const XML_ONLY: &str = r##" Belgian Waffles $5.95Two of our famous Belgian Waffles with plenty of real maple syrup650Strawberry Belgian Waffles$7.95Light Belgian waffles covered with strawberries and whipped cream900Berry-Berry Belgian Waffles$8.95Light Belgian waffles covered with an assortment of fresh berries and whipped cream900French Toast$4.50Thick slices made from our homemade sourdough bread600Homestyle Breakfast$6.95Two eggs, bacon or sausage, toast, and our ever-popular hash browns950"##; const NO_XML: &str = r##"2014-01-16 11:37:05,296 [http-bio-18080-exec-1] DEBUG org.springframework.web.context.request.async.WebAsyncManager - Dispatching request to resume processing Jan 16, 2014 6:37:05 PM org.apache.coyote.http11.AbstractHttp11Processor process SEVERE: Error processing request java.lang.IllegalStateException: Calling [asyncComplete()] is not valid for a request with Async state [MUST_DISPATCH] at org.apache.coyote.AsyncStateMachine.asyncComplete(AsyncStateMachine.java:227) at org.apache.coyote.http11.Http11Processor.actionInternal(Http11Processor.java:358) at org.apache.coyote.http11.AbstractHttp11Processor.action(AbstractHttp11Processor.java:871) at org.apache.coyote.Request.action(Request.java:344) at org.apache.catalina.core.AsyncContextImpl.complete(AsyncContextImpl.java:92) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:140) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:409) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1044) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:722)"##; #[bench] fn pretty_xml_bench(b: &mut Bencher) { let source = XML_LOG.to_string(); b.iter(|| pretty_xml(source.clone()) ) } #[bench] fn pretty_xml_only_bench(b: &mut Bencher) { let source = XML_ONLY.to_string(); b.iter(|| pretty_xml(source.clone()) ) } #[bench] fn pretty_no_xml_bench(b: &mut Bencher) { let source = NO_XML.to_string(); b.iter(|| pretty_xml(source.clone()) ) }