1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-11-14 19:16:42 +00:00
Ryujinx/ARMeilleure/Diagnostics/Logger.cs
Cristallix 4738113f29
Suppress warnings from fields never used or never assigned (CS0169 and CS0649) (#919)
* chore : disable unwanted warnings and minor code cleanup

* chore : remove more warnings

* fix : reorder struct correctly

* fix : restore _isKernel and remove useless comment

* fix : copy/paste error

* fix : restore CallMethod call

* fix : whitespace

* chore : clean using

* feat : remove warnings

* fix : simplify warning removal on struct

* fix : revert fields deletion and code clean up

* fix : re-add RE value

* fix : typo
2020-04-21 07:59:59 +10:00

61 lines
No EOL
1.4 KiB
C#

using ARMeilleure.Translation;
using System;
using System.Diagnostics;
namespace ARMeilleure.Diagnostics
{
static class Logger
{
#pragma warning disable CS0169
private static long _startTime;
private static long[] _accumulatedTime;
#pragma warning restore CS0196
static Logger()
{
_accumulatedTime = new long[(int)PassName.Count];
}
public static void StartPass(PassName name)
{
#if M_DEBUG
WriteOutput(name + " pass started...");
_startTime = Stopwatch.GetTimestamp();
#endif
}
public static void EndPass(PassName name, ControlFlowGraph cfg)
{
#if M_DEBUG
EndPass(name);
WriteOutput("IR after " + name + " pass:");
WriteOutput(IRDumper.GetDump(cfg));
#endif
}
public static void EndPass(PassName name)
{
#if M_DEBUG
long elapsedTime = Stopwatch.GetTimestamp() - _startTime;
_accumulatedTime[(int)name] += elapsedTime;
WriteOutput($"{name} pass ended after {GetMilliseconds(_accumulatedTime[(int)name])} ms...");
#endif
}
private static long GetMilliseconds(long ticks)
{
return (long)(((double)ticks / Stopwatch.Frequency) * 1000);
}
private static void WriteOutput(string text)
{
Console.WriteLine(text);
}
}
}