garydgregory commented on a change in pull request #482:
URL: https://github.com/apache/commons-lang/pull/482#discussion_r385869968



##########
File path: src/main/java/org/apache/commons/lang3/time/StopWatch.java
##########
@@ -606,4 +681,175 @@ public void unsplit() {
         this.splitState = SplitState.UNSPLIT;
     }
 
+    /**
+     * Stops the watch and returns the list of splits with duration on each 
split
+     * @return list of splits
+     */
+    public List<Split> getProcessedSplits() {
+        return getProcessedSplits(false);
+    }
+
+    /**
+     * Stops the watch and returns the list of splits with duration on each 
split (using milliseconds)
+     * @return list of splits
+     */
+    public List<Split> getNanoProcessedSplits() {
+        return getProcessedSplits(true);
+    }
+
+    /**
+     * Stops the watch and returns the list of splits with duration on each 
split
+     *
+     * @param useNanos if must use nanoseconds precision
+     * @return list of splits
+     */
+    public List<Split> getProcessedSplits(boolean useNanos) {

Review comment:
       Using a boolean switch here feels weird to me. Java has a TimeUnit enum 
for things like this, I'd rather see a TimeUnit here. WDYT?

##########
File path: src/main/java/org/apache/commons/lang3/time/StopWatch.java
##########
@@ -481,6 +490,61 @@ public void split() {
         this.splitState = SplitState.SPLIT;
     }
 
+    /**
+     * <p>
+     * Splits the time to track the elapsed time between two consecutive 
{@code split()} calls.
+     * The label specified is used to identify each split
+     * </p>
+     *
+     * <p>
+     * After calling {@link #stop()}, we can call {@link #getReport()} to have 
a report with all time between each {@code split()} call, example:
+     * </p>
+     *
+     * <pre>
+     * 1 00:14:00.000
+     * 2 00:02:00.000
+     * 3 00:04:00.000
+     * </pre>
+     *
+     * @param label A number to identify this split
+     *
+     * @throws IllegalStateException
+     *             if the StopWatch is not running.
+     * @since 3.10
+     */
+    public void split(int label) {
+        split(String.valueOf(label));
+    }
+
+    /**
+     * <p>
+     * Splits the time to track the elapsed time between two consecutive 
{@code split()} calls.
+     * The label specified is used to identify each split
+     * </p>
+     *
+     * <p>
+     * After calling {@link #stop()}, we can call {@link #getReport()} to have 
a report with all time between each {@code split()} call, example:
+     * </p>
+     *
+     * <pre>
+     * Baking cookies  00:14:00.000
+     * Serving         00:02:00.000
+     * Eating          00:04:00.000
+     * </pre>
+     *
+     * @param label A message for string presentation.
+     *
+     * @throws IllegalStateException
+     *             if the StopWatch is not running.
+     * @since 3.10
+     */
+    public void split(String label) {
+        if (this.runningState != State.RUNNING) {
+            throw new IllegalStateException("Stopwatch is not running. ");

Review comment:
       You have an extra space in the message.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to