diff --git a/OpenRa.FileFormats/OpenRa.FileFormats.csproj b/OpenRa.FileFormats/OpenRa.FileFormats.csproj index a6a3fe5463..8e12639d1b 100644 --- a/OpenRa.FileFormats/OpenRa.FileFormats.csproj +++ b/OpenRa.FileFormats/OpenRa.FileFormats.csproj @@ -76,6 +76,9 @@ + + + diff --git a/OpenRa.FileFormats/Support/Log.cs b/OpenRa.FileFormats/Support/Log.cs new file mode 100755 index 0000000000..6a564fe943 --- /dev/null +++ b/OpenRa.FileFormats/Support/Log.cs @@ -0,0 +1,19 @@ +using System.IO; + +namespace OpenRa +{ + public static class Log + { + static StreamWriter writer = File.CreateText("log.txt"); + + static Log() + { + writer.AutoFlush = true; + } + + public static void Write(string format, params object[] args) + { + writer.WriteLine(format, args); + } + } +} diff --git a/OpenRa.FileFormats/Support/Stopwatch.cs b/OpenRa.FileFormats/Support/Stopwatch.cs new file mode 100755 index 0000000000..0bb65e3226 --- /dev/null +++ b/OpenRa.FileFormats/Support/Stopwatch.cs @@ -0,0 +1,33 @@ +using System.Runtime.InteropServices; + +namespace OpenRa.Support +{ + public class Stopwatch + { + [DllImport("kernel32.dll")] + static extern bool QueryPerformanceCounter(out long value); + [DllImport("kernel32.dll")] + static extern bool QueryPerformanceFrequency(out long frequency); + + long freq, start; + + public Stopwatch() + { + QueryPerformanceFrequency(out freq); + QueryPerformanceCounter(out start); + } + + public double ElapsedTime() + { + long current; + QueryPerformanceCounter(out current); + + return (current - start) / (double)freq; + } + + public void Reset() + { + QueryPerformanceCounter(out start); + } + } +} diff --git a/OpenRa.FileFormats/Support/Timer.cs b/OpenRa.FileFormats/Support/Timer.cs new file mode 100755 index 0000000000..e9716ea140 --- /dev/null +++ b/OpenRa.FileFormats/Support/Timer.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace OpenRa.Support +{ + public static class Timer + { + static Stopwatch sw = new Stopwatch(); + static double lastTime = 0; + + public static void Time( string message ) + { + var time = sw.ElapsedTime(); + Log.Write( message, time - lastTime ); + lastTime = time; + } + } +} diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index 4a08e782e9..fffe153fe9 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -133,7 +133,6 @@ - @@ -180,7 +179,6 @@ -