From a51004fd1ac4af27a882dc52b5d8999eeb27f8a2 Mon Sep 17 00:00:00 2001 From: Ruslans Tarasovs Date: Wed, 8 May 2024 12:38:24 +0300 Subject: [PATCH] Print out fractional part of the duration. --- .../persistence/snapshot/SnapshotStorePerfSpec.scala | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/src/test/scala/akka/persistence/snapshot/SnapshotStorePerfSpec.scala b/tests/src/test/scala/akka/persistence/snapshot/SnapshotStorePerfSpec.scala index ca2494cc2..6cc012df5 100644 --- a/tests/src/test/scala/akka/persistence/snapshot/SnapshotStorePerfSpec.scala +++ b/tests/src/test/scala/akka/persistence/snapshot/SnapshotStorePerfSpec.scala @@ -11,6 +11,7 @@ import com.typesafe.config.{Config, ConfigFactory} import java.nio.charset.StandardCharsets import java.time.Instant +import java.time.temporal.ChronoUnit import scala.concurrent.duration._ object SnapshotStorePerfSpec { @@ -238,7 +239,7 @@ abstract class SnapshotStorePerfSpec(config: Config) } val response = testProbe.expectMsgType[SnapshotsSaved](awaitDuration) val duration = response.duration.toNanos / 1000000.0 - info(s"Average time: ${duration} milliseconds") + info(f"Average time: $duration%.2f milliseconds") p1 ! ResetCounter } } @@ -248,8 +249,8 @@ abstract class SnapshotStorePerfSpec(config: Config) benchActor(snapshotCount) testProbe.expectMsgType[SnapshotOffer](awaitDuration) val finishedAt = Instant.now() - val duration = (finishedAt.toEpochMilli - startedAt.toEpochMilli).millis - info(s"Recovering snapshot took $duration") + val duration = startedAt.until(finishedAt, ChronoUnit.NANOS) / 1000000.0 + info(f"Recovering snapshot took $duration%.2f milliseconds") // wait until events recovered testProbe.expectMsgType[RecoveryCompleted](awaitDuration) @@ -267,8 +268,8 @@ abstract class SnapshotStorePerfSpec(config: Config) benchActor(snapshotCount) testProbe.expectMsg(awaitDuration, EventsFoundAfterSnapshot) val finishedAt = Instant.now() - val duration = (finishedAt.toEpochMilli - startedAt.toEpochMilli).millis - info(s"Recovering snapshot took $duration") + val duration = startedAt.until(finishedAt, ChronoUnit.NANOS) / 1000000.0 + info(f"Recovering snapshot took $duration%.2f milliseconds") // wait until events recovered testProbe.expectMsgType[RecoveryCompleted](awaitDuration)