diff --git a/broker/src/main/java/org/eclipse/moquette/spi/impl/SimpleMessaging.java b/broker/src/main/java/org/eclipse/moquette/spi/impl/SimpleMessaging.java index 9dd2cdb8..f639a58e 100644 --- a/broker/src/main/java/org/eclipse/moquette/spi/impl/SimpleMessaging.java +++ b/broker/src/main/java/org/eclipse/moquette/spi/impl/SimpleMessaging.java @@ -66,6 +66,7 @@ public class SimpleMessaging implements IMessaging, EventHandler { private final ProtocolProcessor m_processor = new ProtocolProcessor(); private final AnnotationSupport annotationSupport = new AnnotationSupport(); + private boolean benchmarkEnabled = false; CountDownLatch m_stopLatch; @@ -158,8 +159,10 @@ public class SimpleMessaging implements IMessaging, EventHandler { try { long startTime = System.nanoTime(); annotationSupport.dispatch(session, message); - long delay = System.nanoTime() - startTime; - histogram.recordValue(delay); + if (benchmarkEnabled) { + long delay = System.nanoTime() - startTime; + histogram.recordValue(delay); + } } catch (Throwable th) { LOG.error("Grave error processing the message {} for {}", message, session, th); } @@ -167,6 +170,8 @@ public class SimpleMessaging implements IMessaging, EventHandler { } private void processInit(Properties props) { + benchmarkEnabled = Boolean.parseBoolean(System.getProperty("moquette.processor.benchmark", "false")); + //TODO use a property to select the storage path MapDBPersistentStore mapStorage = new MapDBPersistentStore(); m_storageService = mapStorage; @@ -201,7 +206,9 @@ public class SimpleMessaging implements IMessaging, EventHandler { subscriptions = null; m_stopLatch.countDown(); - //log metrics - histogram.outputPercentileDistribution(System.out, 1000.0); + if (benchmarkEnabled) { + //log metrics + histogram.outputPercentileDistribution(System.out, 1000.0); + } } }