private static void ExecutePartial()

in Microsoft.Shared.Dna.Json.Profile/Profiler.cs [103:135]


        private static void ExecutePartial<T>(object state) where T : IProfile, new()
        {
            ExecuteState asExecute = state as ExecuteState;
            T profile = new T();
            Stopwatch watch = new Stopwatch();
            for (int warmup = asExecute.Iterations / 10; warmup > 0; warmup--)
            {
                profile.Execute(watch);
            }

            bool valid = false;
            for (int i = 0; i < asExecute.Iterations; i++)
            {
                try
                {
                    watch.Restart();
                    valid = profile.Execute(watch);
                    watch.Stop();
                }
                catch
                {
                    valid = false;
                }

                if (valid)
                {
                    asExecute.Total += watch.ElapsedTicks;
                    asExecute.Count++;
                }

                asExecute.Valid = asExecute.Valid && valid;
            }
        }