diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index bcf50f1fd1..e7b89e8261 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -478,7 +478,7 @@ namespace OpenRA Tick(orderManager); - var waitTime = Math.Min(idealFrameTime - sw.ElapsedTime(), 1); + var waitTime = Math.Min(idealFrameTime - sw.Elapsed.TotalSeconds, 1); if (waitTime > 0) System.Threading.Thread.Sleep(TimeSpan.FromSeconds(waitTime)); } diff --git a/OpenRA.Game/Settings.cs b/OpenRA.Game/Settings.cs index ae463b48f4..813325a9bb 100644 --- a/OpenRA.Game/Settings.cs +++ b/OpenRA.Game/Settings.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2013 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2014 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made * available to you under the terms of the GNU General Public License * as published by the Free Software Foundation. For more information, @@ -71,7 +71,7 @@ namespace OpenRA public bool BotDebug = false; public bool PerfText = false; public bool PerfGraph = false; - public float LongTickThreshold = 0.001f; + public TimeSpan LongTickThreshold = TimeSpan.FromMilliseconds(1d); public bool SanityCheckUnsyncedCode = false; public int Samples = 25; public bool IgnoreVersionMismatch = false; diff --git a/OpenRA.Game/Support/PerfHistory.cs b/OpenRA.Game/Support/PerfHistory.cs index 51d54dbfcc..a226904483 100644 --- a/OpenRA.Game/Support/PerfHistory.cs +++ b/OpenRA.Game/Support/PerfHistory.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2014 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made * available to you under the terms of the GNU General Public License * as published by the Free Software Foundation. For more information, @@ -116,7 +116,7 @@ namespace OpenRA.Support public void Dispose() { - PerfHistory.Increment(Item, sw.ElapsedTime() * 1000); + PerfHistory.Increment(Item, sw.Elapsed.TotalMilliseconds); } } } diff --git a/OpenRA.Game/Support/Stopwatch.cs b/OpenRA.Game/Support/Stopwatch.cs index 22790e830f..76d2e5b3ae 100755 --- a/OpenRA.Game/Support/Stopwatch.cs +++ b/OpenRA.Game/Support/Stopwatch.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2014 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made * available to you under the terms of the GNU General Public License * as published by the Free Software Foundation. For more information, @@ -13,14 +13,15 @@ namespace OpenRA.Support public class Stopwatch { System.Diagnostics.Stopwatch sw; - public Stopwatch () + + public Stopwatch() { Reset(); } - public double ElapsedTime() + public System.TimeSpan Elapsed { - return sw.Elapsed.TotalMilliseconds / 1000.0; + get { return this.sw.Elapsed; } } public void Reset() diff --git a/OpenRA.Game/Support/Timer.cs b/OpenRA.Game/Support/Timer.cs index 6463f7a1fe..9b3b42ee93 100755 --- a/OpenRA.Game/Support/Timer.cs +++ b/OpenRA.Game/Support/Timer.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2014 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made * available to you under the terms of the GNU General Public License * as published by the Free Software Foundation. For more information, @@ -13,14 +13,14 @@ namespace OpenRA.Support public static class Timer { static Stopwatch sw = new Stopwatch(); - static double lastTime = 0; + static System.TimeSpan lastTime; public static void Time( string message ) { - var time = sw.ElapsedTime(); + var time = sw.Elapsed; var dt = time - lastTime; - if( dt > 0.0001 ) - Log.Write("perf", message, dt ); + if( dt.TotalSeconds > 0.0001 ) + Log.Write("perf", message, dt.TotalSeconds ); lastTime = time; } } diff --git a/OpenRA.Game/Traits/Util.cs b/OpenRA.Game/Traits/Util.cs index 6573964eca..0b347d4e67 100755 --- a/OpenRA.Game/Traits/Util.cs +++ b/OpenRA.Game/Traits/Util.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2013 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2014 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made * available to you under the terms of the GNU General Public License * as published by the Free Software Foundation. For more information, @@ -83,9 +83,9 @@ namespace OpenRA.Traits var sw = new Stopwatch(); act = act.Tick(self); - var dt = sw.ElapsedTime(); + var dt = sw.Elapsed; if (dt > Game.Settings.Debug.LongTickThreshold) - Log.Write("perf", "[{2}] Activity: {0} ({1:0.000} ms)", prev, dt * 1000, Game.LocalTick); + Log.Write("perf", "[{2}] Activity: {0} ({1:0.000} ms)", prev, dt.TotalMilliseconds, Game.LocalTick); if (prev == act) break; diff --git a/OpenRA.Game/WorldUtils.cs b/OpenRA.Game/WorldUtils.cs index 7949f2f64f..23141fef10 100755 --- a/OpenRA.Game/WorldUtils.cs +++ b/OpenRA.Game/WorldUtils.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2014 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made * available to you under the terms of the GNU General Public License * as published by the Free Software Foundation. For more information, @@ -171,17 +171,17 @@ namespace OpenRA } } - public static void DoTimed(this IEnumerable e, Action a, string text, double time) + public static void DoTimed(this IEnumerable e, Action a, string text, TimeSpan time) { var sw = new Stopwatch(); e.Do(x => { - var t = sw.ElapsedTime(); + var t = sw.Elapsed; a(x); - var dt = sw.ElapsedTime() - t; + var dt = sw.Elapsed - t; if (dt > time) - Log.Write("perf", text, x, dt * 1000, Game.LocalTick); + Log.Write("perf", text, x, dt.TotalMilliseconds, Game.LocalTick); }); } diff --git a/OpenRA.Mods.Cnc/CncLoadScreen.cs b/OpenRA.Mods.Cnc/CncLoadScreen.cs index 06685d47dc..069768d494 100644 --- a/OpenRA.Mods.Cnc/CncLoadScreen.cs +++ b/OpenRA.Mods.Cnc/CncLoadScreen.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2014 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made * available to you under the terms of the GNU General Public License * as published by the Free Software Foundation. For more information, @@ -76,7 +76,7 @@ namespace OpenRA.Mods.Cnc public void Display() { - if (r == null || loadTimer.ElapsedTime() < 0.25) + if (r == null || loadTimer.Elapsed.TotalSeconds < 0.25) return; loadTimer.Reset(); diff --git a/OpenRA.Mods.RA/DefaultLoadScreen.cs b/OpenRA.Mods.RA/DefaultLoadScreen.cs index 5d664e2988..ef9427ff1a 100644 --- a/OpenRA.Mods.RA/DefaultLoadScreen.cs +++ b/OpenRA.Mods.RA/DefaultLoadScreen.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2013 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2014 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made * available to you under the terms of the GNU General Public License * as published by the Free Software Foundation. For more information, @@ -55,7 +55,7 @@ namespace OpenRA.Mods.RA return; // Update text at most every 0.5 seconds - if (lastUpdate.ElapsedTime() < 0.5) + if (lastUpdate.Elapsed.TotalSeconds < 0.5) return; if (r.Fonts == null) diff --git a/OpenRA.Mods.RA/World/DomainIndex.cs b/OpenRA.Mods.RA/World/DomainIndex.cs index dae2a6ca05..1b9dfec858 100644 --- a/OpenRA.Mods.RA/World/DomainIndex.cs +++ b/OpenRA.Mods.RA/World/DomainIndex.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2013 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2014 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made * available to you under the terms of the GNU General Public License * as published by the Free Software Foundation. For more information, @@ -241,7 +241,7 @@ namespace OpenRA.Mods.RA domain += 1; } - Log.Write("debug", "{0}: Found {1} domains. Took {2} s", map.Title, domain-1, timer.ElapsedTime()); + Log.Write("debug", "{0}: Found {1} domains. Took {2} s", map.Title, domain-1, timer.Elapsed.TotalSeconds); } } }