@@ -10,6 +10,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -484,7 +485,7 @@ namespace OpenRA
|
||||
{
|
||||
if (Settings.Graphics.CapFramerate)
|
||||
{
|
||||
var sw = new Stopwatch();
|
||||
var sw = Stopwatch.StartNew();
|
||||
|
||||
Tick(orderManager);
|
||||
|
||||
|
||||
@@ -281,7 +281,6 @@
|
||||
<Compile Include="Primitives\ActionQueue.cs" />
|
||||
<Compile Include="Primitives\Bits.cs" />
|
||||
<Compile Include="Primitives\Cache.cs" />
|
||||
<Compile Include="Primitives\Cached.cs" />
|
||||
<Compile Include="Primitives\DisposableAction.cs" />
|
||||
<Compile Include="Primitives\float2.cs" />
|
||||
<Compile Include="Primitives\int2.cs" />
|
||||
@@ -290,9 +289,7 @@
|
||||
<Compile Include="Primitives\ObservableDictionary.cs" />
|
||||
<Compile Include="Primitives\Pair.cs" />
|
||||
<Compile Include="Primitives\PriorityQueue.cs" />
|
||||
<Compile Include="Primitives\Set.cs" />
|
||||
<Compile Include="Support\Log.cs" />
|
||||
<Compile Include="Support\Stopwatch.cs" />
|
||||
<Compile Include="Support\PerfTimer.cs" />
|
||||
<Compile Include="Exts.cs" />
|
||||
<Compile Include="Hotkey.cs" />
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
|
||||
namespace OpenRA.Primitives
|
||||
{
|
||||
public class Cached<T>
|
||||
{
|
||||
Func<T> p;
|
||||
T value;
|
||||
bool hasValue;
|
||||
|
||||
public Cached(Func<T> p)
|
||||
{
|
||||
if (p == null)
|
||||
throw new ArgumentNullException();
|
||||
|
||||
this.p = p;
|
||||
}
|
||||
|
||||
public T Value
|
||||
{
|
||||
get
|
||||
{
|
||||
if (hasValue)
|
||||
return value;
|
||||
|
||||
value = p();
|
||||
hasValue = true;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public T Force() { return Value; }
|
||||
|
||||
public void Invalidate()
|
||||
{
|
||||
hasValue = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Cached
|
||||
{
|
||||
public static Cached<T> New<T>(Func<T> p) { return new Cached<T>(p); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenRA.Primitives
|
||||
{
|
||||
public class Set<T> : IEnumerable<T>
|
||||
{
|
||||
Dictionary<T, bool> data = new Dictionary<T, bool>();
|
||||
|
||||
public void Add( T obj )
|
||||
{
|
||||
data.Add( obj, false );
|
||||
if( OnAdd != null )
|
||||
OnAdd( obj );
|
||||
}
|
||||
|
||||
public void Remove( T obj )
|
||||
{
|
||||
data.Remove( obj );
|
||||
if( OnRemove != null )
|
||||
OnRemove( obj );
|
||||
}
|
||||
|
||||
public event Action<T> OnAdd;
|
||||
public event Action<T> OnRemove;
|
||||
|
||||
public IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
return data.Keys.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
public bool Contains( T obj ) { return data.ContainsKey(obj); }
|
||||
|
||||
public Set( params T[] ts )
|
||||
{
|
||||
foreach( var t in ts )
|
||||
Add(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using OpenRA.Primitives;
|
||||
|
||||
@@ -106,7 +107,7 @@ namespace OpenRA.Support
|
||||
|
||||
public class PerfSample : IDisposable
|
||||
{
|
||||
readonly Stopwatch sw = new Stopwatch();
|
||||
readonly Stopwatch sw = Stopwatch.StartNew();
|
||||
readonly string Item;
|
||||
|
||||
public PerfSample(string item)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
@@ -16,7 +17,7 @@ namespace OpenRA.Support
|
||||
{
|
||||
public class PerfTimer : IDisposable
|
||||
{
|
||||
readonly Stopwatch sw = new Stopwatch();
|
||||
readonly Stopwatch sw = Stopwatch.StartNew();
|
||||
readonly string Name;
|
||||
|
||||
//
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* 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,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
namespace OpenRA.Support
|
||||
{
|
||||
public class Stopwatch
|
||||
{
|
||||
System.Diagnostics.Stopwatch sw;
|
||||
|
||||
public Stopwatch()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
public System.TimeSpan Elapsed
|
||||
{
|
||||
get { return this.sw.Elapsed; }
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
sw = System.Diagnostics.Stopwatch.StartNew();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using OpenRA.Support;
|
||||
|
||||
@@ -81,7 +82,7 @@ namespace OpenRA.Traits
|
||||
{
|
||||
var prev = act;
|
||||
|
||||
var sw = new Stopwatch();
|
||||
var sw = Stopwatch.StartNew();
|
||||
act = act.Tick(self);
|
||||
var dt = sw.Elapsed;
|
||||
if (dt > Game.Settings.Debug.LongTickThreshold)
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace OpenRA
|
||||
public class World
|
||||
{
|
||||
internal TraitDictionary traitDict = new TraitDictionary();
|
||||
Set<Actor> actors = new Set<Actor>();
|
||||
HashSet<Actor> actors = new HashSet<Actor>();
|
||||
List<IEffect> effects = new List<IEffect>();
|
||||
Queue<Action<World>> frameEndActions = new Queue<Action<World>>();
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.FileFormats;
|
||||
@@ -173,7 +174,7 @@ namespace OpenRA
|
||||
|
||||
public static void DoTimed<T>(this IEnumerable<T> e, Action<T> a, string text, TimeSpan time)
|
||||
{
|
||||
var sw = new Stopwatch();
|
||||
var sw = Stopwatch.StartNew();
|
||||
|
||||
e.Do(x =>
|
||||
{
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.FileSystem;
|
||||
@@ -22,7 +23,7 @@ namespace OpenRA.Mods.Cnc
|
||||
public class CncLoadScreen : ILoadScreen
|
||||
{
|
||||
Dictionary<string, string> loadInfo;
|
||||
Stopwatch loadTimer = new Stopwatch();
|
||||
Stopwatch loadTimer = Stopwatch.StartNew();
|
||||
Sprite[] ss;
|
||||
int loadTick;
|
||||
float2 nodPos, gdiPos, evaPos;
|
||||
@@ -79,7 +80,7 @@ namespace OpenRA.Mods.Cnc
|
||||
if (r == null || loadTimer.Elapsed.TotalSeconds < 0.25)
|
||||
return;
|
||||
|
||||
loadTimer.Reset();
|
||||
loadTimer.Restart();
|
||||
|
||||
loadTick = ++loadTick % 8;
|
||||
r.BeginFrame(float2.Zero, 1f);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.FileSystem;
|
||||
@@ -23,7 +24,7 @@ namespace OpenRA.Mods.RA
|
||||
public class DefaultLoadScreen : ILoadScreen
|
||||
{
|
||||
Dictionary<string, string> info;
|
||||
Stopwatch lastUpdate = new Stopwatch();
|
||||
Stopwatch lastUpdate = Stopwatch.StartNew();
|
||||
Renderer r;
|
||||
|
||||
Rectangle stripeRect;
|
||||
@@ -61,7 +62,7 @@ namespace OpenRA.Mods.RA
|
||||
if (r.Fonts == null)
|
||||
return;
|
||||
|
||||
lastUpdate.Reset();
|
||||
lastUpdate.Restart();
|
||||
var text = messages.Random(Game.CosmeticRandom);
|
||||
var textSize = r.Fonts["Bold"].Measure(text);
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
@@ -187,7 +188,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
void BuildDomains(World world)
|
||||
{
|
||||
var timer = new Stopwatch();
|
||||
var timer = Stopwatch.StartNew();
|
||||
var map = world.Map;
|
||||
|
||||
var domain = 1;
|
||||
|
||||
Reference in New Issue
Block a user