Make Stopwatch.ElapsedTime() a property and TimeSpan
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<T>(this IEnumerable<T> e, Action<T> a, string text, double time)
|
||||
public static void DoTimed<T>(this IEnumerable<T> e, Action<T> 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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user