コード例 #1
0
ファイル: ActivityUtils.cs プロジェクト: dnqbob/OpenRA
        public static Activity RunActivity(Actor self, Activity act)
        {
            // PERF: This is a hot path and must run with minimal added overhead.
            // If there are no activities we can bail straight away and save ourselves the overhead of setting up the perf logging.
            if (act == null)
            {
                return(act);
            }

            var perfLogger = new PerfTickLogger();

            perfLogger.Start();
            while (act != null)
            {
                var prev = act;
                act = act.TickOuter(self);
                perfLogger.LogTickAndRestartTimer("Activity", prev);

                if (act == prev)
                {
                    break;
                }
            }

            return(act);
        }
コード例 #2
0
ファイル: WorldUtils.cs プロジェクト: dnqbob/OpenRA
        public static void DoTimed <T>(this IEnumerable <T> e, Action <T> a, string text)
        {
            // PERF: This is a hot path and must run with minimal added overhead, so we enumerate manually
            // to allow us to call PerfTickLogger only once per iteration in the normal case.
            var perfLogger = new PerfTickLogger();

            using (var enumerator = e.GetEnumerator())
            {
                perfLogger.Start();
                while (enumerator.MoveNext())
                {
                    a(enumerator.Current);
                    perfLogger.LogTickAndRestartTimer(text, enumerator.Current);
                }
            }
        }