diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/StopWatch.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/StopWatch.java index 40cef63f863..419fce6fea6 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/StopWatch.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/StopWatch.java @@ -96,7 +96,7 @@ public class StopWatch { * * @see #formatMillis(long) */ - public String formatMillisPerOperation(int theNumOperations) { + public String formatMillisPerOperation(long theNumOperations) { double millisPerOperation = (((double) getMillis()) / Math.max(1.0, theNumOperations)); return formatMillis(millisPerOperation); } @@ -163,9 +163,9 @@ public class StopWatch { * this method will return 15 *

* - * @see #getThroughput(int, TimeUnit) + * @see #getThroughput(long, TimeUnit) */ - public String formatThroughput(int theNumOperations, TimeUnit theUnit) { + public String formatThroughput(long theNumOperations, TimeUnit theUnit) { double throughput = getThroughput(theNumOperations, theUnit); return new DecimalFormat("0.0").format(throughput); } @@ -202,8 +202,8 @@ public class StopWatch { /** * @param theNumOperations Ok for this to be 0, it will be treated as 1 */ - public int getMillisPerOperation(int theNumOperations) { - return (int) (((double) getMillis()) / Math.max(1.0, theNumOperations)); + public long getMillisPerOperation(long theNumOperations) { + return (long) (((double) getMillis()) / Math.max(1.0, theNumOperations)); } public Date getStartedDate() { @@ -219,7 +219,7 @@ public class StopWatch { * this method will return 15 *

* - * @see #formatThroughput(int, TimeUnit) + * @see #formatThroughput(long, TimeUnit) */ public double getThroughput(long theNumOperations, TimeUnit theUnit) { if (theNumOperations <= 0) { diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/util/StopWatchTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/util/StopWatchTest.java index 0d6fa51f749..192c47f6b0e 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/util/StopWatchTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/util/StopWatchTest.java @@ -141,11 +141,11 @@ public class StopWatchTest { int minutes = 60; StopWatch sw = new StopWatch(DateUtils.addMinutes(new Date(), -minutes)); int numOperations = 60; - int millis = sw.getMillisPerOperation(numOperations); + long millis = sw.getMillisPerOperation(numOperations); ourLog.info("{} operations in {}ms = {}ms / operation", numOperations, minutes * DateUtils.MILLIS_PER_MINUTE, millis); - assertThat(millis, Matchers.lessThan(62000)); - assertThat(millis, Matchers.greaterThan(58000)); + assertThat(millis, Matchers.lessThan(62000L)); + assertThat(millis, Matchers.greaterThan(58000L)); } @Test