uBIMEarthTools/uBIMEarthTools/MethodTimeLogger.cs
2024-09-04 17:44:01 +08:00

31 lines
853 B
C#

using System;
using System.Diagnostics;
using System.Reflection;
//[assembly: MethodTimer.Time]
namespace uBIMEarthTools
{
public static class MethodTimeLogger
{
public static void Log(MethodBase methodBase, TimeSpan elapsed, string message)
{
var span = new Span()
{
Name = $"{methodBase.DeclaringType.Name} : {methodBase.Name}",
Depth = new StackTrace().FrameCount - 1,
FinishTime = DateTimeOffset.Now.ToUnixTimeMilliseconds(),
TimeSpan = elapsed.TotalMilliseconds
};
Trace.TraceInformation($"{methodBase.Name} : {elapsed.TotalSeconds}");
}
}
public struct Span
{
public string Name;
public double TimeSpan;
public long FinishTime;
public int Depth;
}
}