changeset 1144:dbb7bc5daf60

GlobalConfigMain - "metric-only-summary" option
author Devel 2
date Wed, 10 Jun 2020 12:15:19 +0200
parents 1947030b8b3d
children 20c663622c30
files stress-tester/src/main/java/com/passus/st/GlobalConfigMain.java
diffstat 1 files changed, 12 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/GlobalConfigMain.java	Wed Jun 10 10:48:44 2020 +0200
+++ b/stress-tester/src/main/java/com/passus/st/GlobalConfigMain.java	Wed Jun 10 12:15:19 2020 +0200
@@ -30,6 +30,7 @@
         CliOptions options = cliHelper.options();
         options.addLogLevelOption();
         options.addMetricsFormatOption();
+        options.addOption("mos", "metric-only-summary", false, "Show only summary metrics.");
         return options;
     }
 
@@ -57,6 +58,7 @@
 
             cliHelper.configureLogger(cl);
             final String metricFormat = cl.getOptionValue("mf", "text");
+            final boolean onlySummary = cl.hasOption("mos");
 
             Errors errors = new Errors();
             File configFile = new File(clArgs[0]);
@@ -79,13 +81,14 @@
             final long startTime = System.currentTimeMillis();
             MetricsCollector metricsCollector = testJob.getMetricsCollector();
 
-            ScheduledExecutorService executor;
+            ScheduledExecutorService executor = null;
             if (metricsCollector != null) {
                 metricsCollector.addHandler(summMetricsHandler);
-                executor = Executors.newSingleThreadScheduledExecutor();
-                executor.scheduleAtFixedRate(() -> printMetrics(getMetrics(), startTime, metricFormat), 5, 5, TimeUnit.SECONDS);
-            } else {
-                executor = null;
+
+                if (!onlySummary) {
+                    executor = Executors.newSingleThreadScheduledExecutor();
+                    executor.scheduleAtFixedRate(() -> printMetrics(getMetrics(), startTime, metricFormat), 5, 5, TimeUnit.SECONDS);
+                }
             }
 
             final Logger logger = LogManager.getLogger("GlobalConfigMain");
@@ -95,8 +98,10 @@
             testJob.join();
             logger.debug("TestJob finished");
 
-            if (metricsCollector != null && executor != null) {
-                executor.shutdownNow();
+            if (metricsCollector != null) {
+                if (executor != null) {
+                    executor.shutdownNow();
+                }
                 metricsCollector.collect();
                 metricsCollector.flush(true);
                 printMetrics(getMetrics(), startTime, metricFormat);