title: What is the point of Apache Lang3 StopWatch.split()?
body: <p>I am currently evaluating implementations between Apache StopWatch and Guava's Stopwatch and the split functionality in the former intrigued me, but I am struggling to understand what exactly it does, and what value it has.</p>
  <p>According to the documentation for StopWatch: <a href="https://commons.apache.org/proper/commons-lang/javadocs/api-3.9/org/apache/commons/lang3/time/StopWatch.html" rel="noreferrer">https://commons.apache.org/proper/commons-lang/javadocs/api-3.9/org/apache/commons/lang3/time/StopWatch.html</a></p>
  <blockquote>
  <p>split() the watch to get the time whilst the watch continues in the background. unsplit() will remove the effect of the split. At this point, these three options are available again.</p>
  </blockquote>
  <p>And I found some examples, such as <a href="https://kodejava.org/calculate-timings-using-commons-lang-stopwatch/" rel="noreferrer">this</a>, which offer very little, since it appears split is just cumulative.  The page says the method is for &quot;splitting the time&quot;, which I figured as much based on the method, but the page makes no mention to what that actually means.  It would even appear that this example is utterly wrong, because the docs suggest that you should <code>unsplit</code> before you <code>split</code> again.</p>
  <p>I initially thought it was for the following usecase:</p>
  <pre><code>StopWatch stopwatch = StopWatch.createStarted();
  do something for 5 seconds
  stopwatch.split();
  do something for 10 seconds
  stopwatch.stop();
  System.out.println(stopwatch.getTime());
  System.out.println(stopwatch.getSplitTime());
  </code></pre>
  <p>I thought that stopwatch total time would read as 15 seconds, and stopwatch split time would read as either 10 or 5 seconds, but it appears that both methods output 15 seconds.</p>
  <p>Next, I thought maybe the split value is a delta you can take, and then remove from the total timer, something like:</p>
  <pre><code>StopWatch stopwatch = StopWatch.createStarted();
  do something for 5 seconds
  stopwatch.split();
  do something for 10 seconds
  stopwatch.unsplit();
  stopwatch.stop();
  System.out.println(stopwatch.getTime());
  // System.out.println(stopwatch.getSplitTime()); errors because of unsplit
  </code></pre>
  <p>My thought here was that the split time would be 10 seconds, and when unsplit from the main timer, the main timer would read as 5 seconds... but this seems no different from a <code>suspend()</code> call...  I also tried this, and the timings remain the same nonetheless for me.</p>
  <p>Am I missing something here, or is my interpretation of what this is supposed to do all wrong?</p>