File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
src/main/java/com/rabbitmq/stream/perf Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -187,12 +187,12 @@ public void start(String description) throws Exception {
187187 com .codahale .metrics .Timer latency = metricRegistry .getTimers ().get (metricLatency );
188188
189189 Function <Number , Number > convertDuration =
190- in -> in instanceof Long ? in .longValue () / 1000 : in .doubleValue () / 1000 ;
190+ in -> in instanceof Long ? in .longValue () / 1_000_000 : in .doubleValue () / 1_000_000 ;
191191 Function <com .codahale .metrics .Timer , String > formatLatency =
192192 timer -> {
193193 Snapshot snapshot = timer .getSnapshot ();
194194 return String .format (
195- "latency min/median/75th/95th/99th %.0f/%.0f/%.0f/%.0f/%.0f µs " ,
195+ "latency min/median/75th/95th/99th %.0f/%.0f/%.0f/%.0f/%.0f ms " ,
196196 convertDuration .apply (snapshot .getMin ()),
197197 convertDuration .apply (snapshot .getMedian ()),
198198 convertDuration .apply (snapshot .get75thPercentile ()),
@@ -261,7 +261,7 @@ public void start(String description) throws Exception {
261261 Function <com .codahale .metrics .Timer , String > formatLatencySummary =
262262 histogram ->
263263 String .format (
264- "latency 95th %.0f µs " ,
264+ "latency 95th %.0f ms " ,
265265 convertDuration .apply (latency .getSnapshot ().get95thPercentile ()));
266266
267267 StringBuilder builder = new StringBuilder ("Summary: " );
Original file line number Diff line number Diff line change @@ -664,7 +664,11 @@ public Integer call() throws Exception {
664664 try {
665665 while (true && !Thread .currentThread ().isInterrupted ()) {
666666 rateLimiterCallback .run ();
667- long creationTime = System .nanoTime ();
667+ // Using current time for interoperability with other tools
668+ // and also across different processes.
669+ // This is good enough to measure duration/latency this way
670+ // in a performance tool.
671+ long creationTime = System .currentTimeMillis ();
668672 byte [] payload = new byte [msgSize ];
669673 Utils .writeLong (payload , creationTime );
670674 producer .send (
@@ -716,7 +720,9 @@ public Integer call() throws Exception {
716720 if (messageCount .incrementAndGet () % 100 == 0 ) {
717721 try {
718722 long time = Utils .readLong (message .getBodyAsBinary ());
719- metrics .latency (System .nanoTime () - time , TimeUnit .NANOSECONDS );
723+ // see above why we use current time to measure latency
724+ metrics .latency (
725+ System .currentTimeMillis () - time , TimeUnit .MILLISECONDS );
720726 } catch (Exception e ) {
721727 // not able to read the body, maybe not a message from the tool
722728 }
You can’t perform that action at this time.
0 commit comments