diff --git a/ShareX.HelpersLib/DebugTimer.cs b/ShareX.HelpersLib/DebugTimer.cs index 807bedcad..7927bb43f 100644 --- a/ShareX.HelpersLib/DebugTimer.cs +++ b/ShareX.HelpersLib/DebugTimer.cs @@ -25,12 +25,13 @@ You should have received a copy of the GNU General Public License using System; using System.Diagnostics; +using System.Globalization; namespace ShareX.HelpersLib { public class DebugTimer : IDisposable { - public string Text { get; private set; } + public string Text { get; set; } private Stopwatch timer; @@ -40,7 +41,7 @@ public DebugTimer(string text = null) timer = Stopwatch.StartNew(); } - private void Write(string text, string timeText) + private void Write(string time, string text = null) { if (string.IsNullOrEmpty(text)) { @@ -49,20 +50,22 @@ private void Write(string text, string timeText) if (!string.IsNullOrEmpty(text)) { - timeText = text + ": " + timeText; + Debug.WriteLine(text + ": " + time); + } + else + { + Debug.WriteLine(time); } - - Debug.WriteLine(timeText); - } - - public void WriteElapsedSeconds(string text = null) - { - Write(text, timer.Elapsed.TotalSeconds.ToString("0.000") + " seconds."); } public void WriteElapsedMilliseconds(string text = null) { - Write(text, timer.Elapsed.TotalMilliseconds + " milliseconds."); + Write(timer.Elapsed.TotalMilliseconds.ToString("0.000", CultureInfo.InvariantCulture) + " milliseconds.", text); + } + + public void WriteElapsedSeconds(string text = null) + { + Write(timer.Elapsed.TotalSeconds.ToString("0.000", CultureInfo.InvariantCulture) + " seconds.", text); } public void Dispose()