Archived
1
0
Fork 0
forked from Mirror/Ryujinx
This repository has been archived on 2024-10-11. You can view files and clone it, but cannot push or open issues or pull requests.
jinx/ARMeilleure/Diagnostics/Logger.cs
mageven 492bb6ee5f
Suppress CS0169 CS0649 warns from HID structs (#1222)
Also fix typo in a pragma restore in Logger
2020-05-10 16:02:41 +02: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 CS0169
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);
}
}
}