Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            IOutput output = new MultiOutput(new IOutput[] { new HtmlOutput(), new MarkdownOutput(), new ChartOutput(), new CsvOutput(), new ConsoleOutput() });
            output.Start();

            var containers = ContainerAdapterFactory.CreateAdapters();

            bool onlyUpdateChangedContainers = args != null && args.Any(a => a.Equals("-update", StringComparison.OrdinalIgnoreCase));
            var csvOutputReader = new CsvOutputReader();

            foreach (var container in containers)
            {
                Result result = csvOutputReader.GetExistingResult(container.Name);

                if (result != null)
                {
                    result.Url = container.Url;
                }

                if (!onlyUpdateChangedContainers || result == null || result.Version != container.Version)
                {
                    result = MeasurePerformance(container);
                }

                output.Result(result);
            }

            output.Finish();
        }
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            IOutput output = new MultiOutput(new IOutput[] { new HtmlOutput(), new MarkdownOutput(), new ChartOutput(), new CsvOutput(), new ConsoleOutput() });
            output.Start();

            var containers = new List<Tuple<string, IContainerAdapter>>
            {
                Tuple.Create<string, IContainerAdapter>("No", new NoContainerAdapter()),
                Tuple.Create<string, IContainerAdapter>("AutoFac", new AutofacContainerAdapter()),
                Tuple.Create<string, IContainerAdapter>("Caliburn.Micro", new CaliburnMicroContainer()),
                Tuple.Create<string, IContainerAdapter>("Catel", new CatelContainerAdapter()),
                Tuple.Create<string, IContainerAdapter>("Dynamo", new DynamoContainerAdapter()),
                Tuple.Create<string, IContainerAdapter>("fFastInjector", new FFastInjectorContainerAdapter()),
                Tuple.Create<string, IContainerAdapter>("Funq", new FunqContainerAdapter()),
                Tuple.Create<string, IContainerAdapter>("Griffin", new GriffinContainerAdapter()),
                Tuple.Create<string, IContainerAdapter>("HaveBox", new HaveBoxContainerAdapter()),
                Tuple.Create<string, IContainerAdapter>("Hiro", new HiroContainerAdapter()),
                Tuple.Create<string, IContainerAdapter>("LightCore", new LightCoreContainerAdapter()),
                Tuple.Create<string, IContainerAdapter>("LightInject", new LightInjectContainerAdapter()),
                Tuple.Create<string, IContainerAdapter>("LinFu", new LinFuContainerAdapter()),
                Tuple.Create<string, IContainerAdapter>("Mef", new MefContainerAdapter()),
                Tuple.Create<string, IContainerAdapter>("MicroSliver", new MicroSliverContainerAdapter()),
                Tuple.Create<string, IContainerAdapter>("Mugen", new MugenContainerAdapter()),
                Tuple.Create<string, IContainerAdapter>("Munq", new MunqContainerAdapter()),
                Tuple.Create<string, IContainerAdapter>("Ninject", new NinjectContainerAdapter()),
                Tuple.Create<string, IContainerAdapter>("Petite", new PetiteContainerAdapter()),
                Tuple.Create<string, IContainerAdapter>("SimpleInjector", new SimpleInjectorContainerAdapter()),
                //Tuple.Create<string, IContainerAdapter>("Speedioc", new SpeediocContainerAdapter()),
                Tuple.Create<string, IContainerAdapter>("Spring.NET", new SpringContainerAdapter()),
                Tuple.Create<string, IContainerAdapter>("StructureMap", new StructureMapContainerAdapter()),
                Tuple.Create<string, IContainerAdapter>("StyleMVVM", new StyleMVVMContainerAdapter()),
                Tuple.Create<string, IContainerAdapter>("TinyIOC", new TinyIOCContainerAdapter()),
                Tuple.Create<string, IContainerAdapter>("Unity", new UnityContainerAdapter()),
                Tuple.Create<string, IContainerAdapter>("Windsor", new WindsorContainerAdapter())
            };

            foreach (var container in containers)
            {
                output.Result(MeasurePerformance(container.Item1, container.Item2));
            }

            output.Finish();
        }
Exemplo n.º 3
0
        public static void Main(string[] args)
        {
            var containers = ContainerAdapterFactory.CreateAdapters().ToArray();
            var benchmarks = BenchmarkFactory.CreateBenchmarks().ToArray();

            var benchmarkResults = new List<BenchmarkResult>();
            var existingBenchmarkResults = new List<BenchmarkResult>();

            if (args != null && args.Any(a => a.Equals("-update", StringComparison.OrdinalIgnoreCase)))
            {
                existingBenchmarkResults.AddRange(XmlOutputReader.GetExistingBenchmarkResults(benchmarks, containers));
            }

            foreach (var container in containers)
            {
                AppDomain childDomain = null;

                try
                {
                    AppDomainSetup domainSetup = new AppDomainSetup()
                    {
                        ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
                        ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile,
                        ApplicationName = AppDomain.CurrentDomain.SetupInformation.ApplicationName,
                        LoaderOptimization = LoaderOptimization.MultiDomainHost
                    };

                    childDomain = AppDomain.CreateDomain("AppDomain for " + container.Name, null, domainSetup);

                    ContainerAdapterRuntime runtime = (ContainerAdapterRuntime)childDomain.CreateInstanceAndUnwrap(
                        typeof(ContainerAdapterRuntime).Assembly.FullName,
                        typeof(ContainerAdapterRuntime).FullName);

                    var containerBenchmarkResults = runtime.Run(container.GetType(), existingBenchmarkResults);
                    benchmarkResults.AddRange(containerBenchmarkResults);
                }
                catch (Exception ex)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(
                        " Container '{0}' failed: {1}",
                        container.Name,
                        ex.Message);
                    Console.ResetColor();
                }
                finally
                {
                    if (childDomain != null)
                    {
                        AppDomain.Unload(childDomain);
                    }

                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                    GC.Collect();
                }

                Console.WriteLine();
            }

            IOutput output = new MultiOutput(
                new XmlOutput(),
                new HtmlOutput(),
                new MarkdownOutput(),
                new CsvOutput(),
                new CsvRateOutput(),
                new ChartOutput(),
                new ZipOutput());

            output.Create(benchmarks, benchmarkResults);

            Console.WriteLine("Done");
        }