moved Log, Stopwatch to FileFormats. Added Support/Timer.
This commit is contained in:
@@ -76,6 +76,9 @@
|
|||||||
<Compile Include="ShpReader.cs" />
|
<Compile Include="ShpReader.cs" />
|
||||||
<Compile Include="ShroudPaletteRemap.cs" />
|
<Compile Include="ShroudPaletteRemap.cs" />
|
||||||
<Compile Include="SingleColorRemap.cs" />
|
<Compile Include="SingleColorRemap.cs" />
|
||||||
|
<Compile Include="Support\Log.cs" />
|
||||||
|
<Compile Include="Support\Stopwatch.cs" />
|
||||||
|
<Compile Include="Support\Timer.cs" />
|
||||||
<Compile Include="Terrain.cs" />
|
<Compile Include="Terrain.cs" />
|
||||||
<Compile Include="TileReference.cs" />
|
<Compile Include="TileReference.cs" />
|
||||||
<Compile Include="TileSet.cs" />
|
<Compile Include="TileSet.cs" />
|
||||||
|
|||||||
19
OpenRa.FileFormats/Support/Log.cs
Executable file
19
OpenRa.FileFormats/Support/Log.cs
Executable file
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
33
OpenRa.FileFormats/Support/Stopwatch.cs
Executable file
33
OpenRa.FileFormats/Support/Stopwatch.cs
Executable file
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
20
OpenRa.FileFormats/Support/Timer.cs
Executable file
20
OpenRa.FileFormats/Support/Timer.cs
Executable file
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -133,7 +133,6 @@
|
|||||||
<Compile Include="SupportPowers\ISupportPowerImpl.cs" />
|
<Compile Include="SupportPowers\ISupportPowerImpl.cs" />
|
||||||
<Compile Include="SupportPowers\NullPower.cs" />
|
<Compile Include="SupportPowers\NullPower.cs" />
|
||||||
<Compile Include="Support\OpenAlInterop.cs" />
|
<Compile Include="Support\OpenAlInterop.cs" />
|
||||||
<Compile Include="Support\Stopwatch.cs" />
|
|
||||||
<Compile Include="Support\PerfHistory.cs" />
|
<Compile Include="Support\PerfHistory.cs" />
|
||||||
<Compile Include="Sync.cs" />
|
<Compile Include="Sync.cs" />
|
||||||
<Compile Include="Traits\AcceptsOre.cs" />
|
<Compile Include="Traits\AcceptsOre.cs" />
|
||||||
@@ -180,7 +179,6 @@
|
|||||||
<Compile Include="Player.cs" />
|
<Compile Include="Player.cs" />
|
||||||
<Compile Include="Race.cs" />
|
<Compile Include="Race.cs" />
|
||||||
<Compile Include="Graphics\Sheet.cs" />
|
<Compile Include="Graphics\Sheet.cs" />
|
||||||
<Compile Include="Support\Log.cs" />
|
|
||||||
<Compile Include="PathFinder.cs" />
|
<Compile Include="PathFinder.cs" />
|
||||||
<Compile Include="Graphics\Sequence.cs" />
|
<Compile Include="Graphics\Sequence.cs" />
|
||||||
<Compile Include="Orders\Order.cs" />
|
<Compile Include="Orders\Order.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user