Ejemplo n.º 1
0
        protected static void DoPostfix(object __instance, object __state, MeasurableObjectType type)
        {
            if (!ProfilerPlugin.IsProfiling)
            {
                return;
            }

            var sw = __state as Stopwatch;

            if (sw == null)
            {
                return;
            }

            long time = sw.ElapsedMilliseconds;

            sw.Reset();

            MeasurableObject o = ProfilerPlugin.Instance.Assemblies[__instance.GetType().Assembly][__instance.GetType()].First(c => c.MeasureType == type);

            if (ProfilerPlugin.Instance != null && o.Measures.Count > ProfilerPlugin.Instance.Configuration.Instance.MaxFrameCount)
            {
                // we might do profiling during a reload, so we need to check if instance is null
                return;
            }

            o.Measures.Add(time);
        }
Ejemplo n.º 2
0
 protected EventPatch(MeasurableObjectType @event, HarmonyMethod prefix, HarmonyMethod postfix)
 {
     Prefix      = prefix;
     Postfix     = postfix;
     MeasureType = @event;
 }