From f0c865555beb7fb079280fb7a177a0fcd677b373 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 4 Sep 2015 11:05:15 +0100 Subject: [PATCH] add a GetTimeStampMS method, this returns a time stamp in miliSeconds with the resolution avaiable for StopWatchs. Value in double since it can be large (as machine uptime in high resolution ticks) --- OpenSim/Framework/Util.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 77985bd72f..d1cdaa67c4 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -140,10 +140,14 @@ namespace OpenSim.Framework public static readonly int MAX_THREADPOOL_LEVEL = 3; + public static double TimeStampClockPeriodMS; + static Util() { LogThreadPool = 0; LogOverloads = true; + TimeStampClockPeriodMS = 1000.0D / (double)Stopwatch.Frequency; + m_log.InfoFormat("[UTIL] TimeStamp clock with period of {0}ms", Math.Round(TimeStampClockPeriodMS,6,MidpointRounding.AwayFromZero)); } private static uint nextXferID = 5000; @@ -2662,6 +2666,13 @@ namespace OpenSim.Framework return tcA - tcB; } + // returns a timestamp in ms as double + // using the time resolution avaiable to StopWatch + public static double GetTimeStampMS() + { + return (double)Stopwatch.GetTimestamp() * TimeStampClockPeriodMS; + } + /// /// Formats a duration (given in milliseconds). ///