Пример #1
0
        public static T Capture <T>(string name, Func <T> funcToProfile)
        {
#if AX_PROFILE
            using var timer = new InstrumentationTimer(name);
#endif
            return(funcToProfile());
        }
Пример #2
0
        public static void Capture(string name, Action funcToProfile)
        {
#if AX_PROFILE
            using var timer = new InstrumentationTimer(name);
#endif
            funcToProfile();
        }
Пример #3
0
        public static T Capture <T>(Func <T> funcToProfile)
        {
#if AX_PROFILE
            MethodBase method = new StackTrace().GetFrame(1)?.GetMethod();
            Logger.Assert(method != null, "Should have a caller or stack trace");

            string methodName = method.Name;
            string className  = method.ReflectedType.Name;

            using var timer = new InstrumentationTimer($"{className}::{methodName}");
#endif
            return(funcToProfile());
        }