GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 42557c...66f82e )
by Glythcing
04:18
created

StopWatch()   A

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 2
rs 10
cc 1
1
package io.github.glytching.junit.extension.benchmark;
2
3
import java.util.concurrent.TimeUnit;
4
5
import static java.lang.System.nanoTime;
6
import static java.util.concurrent.TimeUnit.NANOSECONDS;
7
8
/** A simple wrapper for use in reporting test elapsed time in a chosen {@link TimeUnit}. */
9
public class StopWatch {
10
11
  private long start;
12
13
  /** Constructs a StopWatch with a start time equal to the system's current nano time. */
14
  public StopWatch() {
15
    this.start = nanoTime();
16
  }
17
18
  /**
19
   * Returns the duration of since this instance was created. The duration will be converted into
20
   * the given {@code timeUnit}.
21
   *
22
   * @param timeUnit the units in which the duration is returned
23
   * @return The elapsed time converted to the specified units
24
   */
25
  public long duration(TimeUnit timeUnit) {
26
    return timeUnit.convert(nanoTime() - start, NANOSECONDS);
27
  }
28
}
29