File tree 2 files changed +11
-5
lines changed
src/main/java/com/rabbitmq/stream/perf
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 {
187
187
com .codahale .metrics .Timer latency = metricRegistry .getTimers ().get (metricLatency );
188
188
189
189
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 ;
191
191
Function <com .codahale .metrics .Timer , String > formatLatency =
192
192
timer -> {
193
193
Snapshot snapshot = timer .getSnapshot ();
194
194
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 " ,
196
196
convertDuration .apply (snapshot .getMin ()),
197
197
convertDuration .apply (snapshot .getMedian ()),
198
198
convertDuration .apply (snapshot .get75thPercentile ()),
@@ -261,7 +261,7 @@ public void start(String description) throws Exception {
261
261
Function <com .codahale .metrics .Timer , String > formatLatencySummary =
262
262
histogram ->
263
263
String .format (
264
- "latency 95th %.0f µs " ,
264
+ "latency 95th %.0f ms " ,
265
265
convertDuration .apply (latency .getSnapshot ().get95thPercentile ()));
266
266
267
267
StringBuilder builder = new StringBuilder ("Summary: " );
Original file line number Diff line number Diff line change @@ -664,7 +664,11 @@ public Integer call() throws Exception {
664
664
try {
665
665
while (true && !Thread .currentThread ().isInterrupted ()) {
666
666
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 ();
668
672
byte [] payload = new byte [msgSize ];
669
673
Utils .writeLong (payload , creationTime );
670
674
producer .send (
@@ -716,7 +720,9 @@ public Integer call() throws Exception {
716
720
if (messageCount .incrementAndGet () % 100 == 0 ) {
717
721
try {
718
722
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 );
720
726
} catch (Exception e ) {
721
727
// not able to read the body, maybe not a message from the tool
722
728
}
You can’t perform that action at this time.
0 commit comments