File tree Expand file tree Collapse file tree 2 files changed +19
-8
lines changed
java/net/ttddyy/dsproxy/proxy Expand file tree Collapse file tree 2 files changed +19
-8
lines changed Original file line number Diff line number Diff line change 1+ [[changelog-1.11]]
2+ === 1.11
3+
4+ ==== New Features
5+
6+ ==== Improvements
7+
8+ * Use monotonic time to measure the elapsed time (https://github.com/jdbc-observations/datasource-proxy/issues/110[Issue-110]).
9+
10+
11+ ==== Bug Fixes
Original file line number Diff line number Diff line change 11package net .ttddyy .dsproxy .proxy ;
22
3+ import java .util .concurrent .TimeUnit ;
4+
35/**
4- * Factory to create {@link SystemStopwatch} which uses {@code System.currentTimeMillis()}.
5- *
6- * The unit of time is milliseconds.
6+ * Factory to create {@link SystemStopwatch} which uses monotonic time.
7+ * <p> The unit of time is milliseconds.
78 *
89 * @author Tadaya Tsuyukubo
910 * @since 1.5.1
@@ -16,17 +17,16 @@ public Stopwatch create() {
1617 }
1718
1819 /**
19- * Uses {@code System.currentTimeMillis()} to calculate elapsed time.
20- *
21- * The unit of time is milliseconds
20+ * Uses monotonic time to calculate elapsed time.
21+ * <p>The unit of time is milliseconds.
2222 */
2323 public static class SystemStopwatch implements Stopwatch {
2424
2525 private long startTime ;
2626
2727 @ Override
2828 public Stopwatch start () {
29- this .startTime = System .currentTimeMillis ();
29+ this .startTime = System .nanoTime ();
3030 return this ;
3131 }
3232
@@ -37,7 +37,7 @@ public Stopwatch start() {
3737 */
3838 @ Override
3939 public long getElapsedTime () {
40- return System .currentTimeMillis () - this .startTime ;
40+ return TimeUnit . NANOSECONDS . toMillis ( System .nanoTime () - this .startTime ) ;
4141 }
4242
4343 }
You can’t perform that action at this time.
0 commit comments