changeset 1140:3f1884efeb15

Main.printMetrics(MetricsCollection collection, String format)
author Devel 2
date Wed, 10 Jun 2020 10:05:41 +0200
parents 04d179a5e2bf
children c4c4625a8523
files stress-tester/src/main/java/com/passus/st/Main.java
diffstat 1 files changed, 19 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/Main.java	Tue Jun 09 13:42:44 2020 +0200
+++ b/stress-tester/src/main/java/com/passus/st/Main.java	Wed Jun 10 10:05:41 2020 +0200
@@ -2,13 +2,14 @@
 
 import com.passus.commons.ConversionException;
 import com.passus.commons.metric.Metric;
+import com.passus.commons.metric.MetricsCollection;
 import com.passus.commons.service.Registry;
 import com.passus.config.ConfigurationContext;
 import com.passus.st.client.*;
-import com.passus.st.filter.FlowFilter;
 import com.passus.st.client.http.*;
 import com.passus.st.emitter.SessionMapper;
 import com.passus.st.emitter.nio.NioEmitter;
+import com.passus.st.filter.FlowFilter;
 import com.passus.st.metric.FileMetricsCollectionAppender;
 import com.passus.st.metric.MetricSource;
 import com.passus.st.metric.ScheduledMetricsCollector;
@@ -29,7 +30,6 @@
 import static com.passus.st.utils.CliUtils.option;
 
 /**
- *
  * @author Mirosław Hawrot
  */
 public class Main {
@@ -50,22 +50,18 @@
         System.exit(1);
     }
 
-    static void printMetrics(List<Metric> metrics, long startTime) {
-        if (startTime == 0) {
-            return;
-        }
-
+    static void printMetrics(MetricsCollection collection, String format) {
         long endTime = System.currentTimeMillis();
         synchronized (System.out) {
             System.out.println("");
             try {
-                System.out.println("Elapsed time: " + PeriodFormatter.INSTANCE.reverseTransform(endTime - startTime) + ".");
+                System.out.println("Elapsed time: " + PeriodFormatter.INSTANCE.reverseTransform(collection.getEndTimestamp() - collection.getStartTimestamp()) + ".");
             } catch (ConversionException ignored) {
             }
             System.out.println("Metrics:");
 
             String line = "%24s: %s\n";
-            for (Metric metric : metrics) {
+            for (Metric metric : collection.getMetrics()) {
                 System.out.println(metric.getName() + ":");
                 Map<String, Serializable> valuesMap = metric.getAttributesValue();
                 for (Map.Entry<String, Serializable> entry : valuesMap.entrySet()) {
@@ -78,6 +74,20 @@
         }
     }
 
+    static void printMetrics(List<Metric> metrics, long startTime) {
+        printMetrics(metrics, startTime, "text");
+    }
+
+    static void printMetrics(List<Metric> metrics, long startTime, String format) {
+        if (startTime == 0) {
+            return;
+        }
+
+        long endTime = System.currentTimeMillis();
+        MetricsCollection collection = new MetricsCollection(startTime, endTime, metrics);
+        printMetrics(collection, format);
+    }
+
     private Options createOptions() {
         CliOptions options = cliHelper.options();