コード例 #1
0
        public void Run(ProfileConfiguration configuration)
        {
            foreach (var profiledClass in ProfiledClasses
                     .Where(c => !configuration.ClassNames.Any() || configuration.ClassNames.Contains(c.Name))
                     .Where(c => c.Methods.Any(m => !m.IsAsync)))
            {
                var instance = profiledClass.CreateInstance(Cluster);

                if (profiledClass.SetupMethod != null)
                {
                    var setup = profiledClass.SetupMethod.Compile(instance);
                    Output.WriteLine(ConsoleColor.Green, $"Running setup for {profiledClass.Type.Name}");
                    setup();
                }

                foreach (var profiledMethod in profiledClass.Methods.Where(m => !m.IsAsync))
                {
                    var resultsDirectory = Path.Combine(OutputPath, profiledClass.Type.Name, profiledMethod.MethodInfo.Name);
                    var action           = profiledMethod.Compile(instance);

                    Output.WriteLine(
                        ConsoleColor.Green,
                        $"{Name} profiling {profiledClass.Type.Name}.{profiledMethod.MethodInfo.Name}");

                    using (BeginProfiling(resultsDirectory))
                    {
                        for (var i = 0; i < profiledMethod.Attribute.Iterations; i++)
                        {
                            action();
                        }
                    }
                }
            }
        }
コード例 #2
0
        public static ProfileConfiguration Parse(string[] args)
        {
            var configuration = new ProfileConfiguration();

            var classNames = new HashSet <string>();
            var classIndex = Array.IndexOf(args, "Class");

            if (classIndex > -1 && args.Length > classIndex + 1)
            {
                foreach (var className in args[classIndex + 1].Split(','))
                {
                    classNames.Add(className);
                }
            }

            configuration.ClassNames = classNames;
            return(configuration);
        }