Lucene.Net.Support.Time: Added a CurrentTimeMilliseconds() method that is 
similar, but more accurate than Java's System.currentTimeMillis() method and 
can safely be used for elapsed timing


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/a11ca03b
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/a11ca03b
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/a11ca03b

Branch: refs/heads/master
Commit: a11ca03b83c6e67edbea6d99d4db5d2e2c73d78a
Parents: 1b8621b
Author: Shad Storhaug <[email protected]>
Authored: Mon Jul 31 13:39:26 2017 +0700
Committer: Shad Storhaug <[email protected]>
Committed: Wed Aug 2 09:54:15 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net/Support/Time.cs | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a11ca03b/src/Lucene.Net/Support/Time.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Support/Time.cs b/src/Lucene.Net/Support/Time.cs
index cfa5079..cec17e8 100644
--- a/src/Lucene.Net/Support/Time.cs
+++ b/src/Lucene.Net/Support/Time.cs
@@ -1,4 +1,5 @@
 using System;
+using System.Diagnostics;
 
 namespace Lucene.Net.Support
 {
@@ -27,6 +28,14 @@ namespace Lucene.Net.Support
         public static long NanoTime()
         {
             return DateTime.Now.Ticks * TICKS_PER_NANOSECOND;
+            // LUCENENET TODO: Change to
+            // return (Stopwatch.GetTimestamp() / Stopwatch.Frequency) * 
1000000000;
+            // for better accuracy that is not affected by the system clock
+        }
+
+        public static long CurrentTimeMilliseconds()
+        {
+            return (Stopwatch.GetTimestamp() / Stopwatch.Frequency) * 1000;
         }
     }
 }
\ No newline at end of file

Reply via email to