Пример #1
0
        private static void Main(string[] args)
        {
            var switcher = new BenchmarkSwitcher(new[]
            {
                ////typeof(TypelessSerializeBenchmark),
                ////typeof(TypelessDeserializeBenchmark),
                typeof(DeserializeBenchmark),
                typeof(SerializeBenchmark),
                typeof(DictionaryLookupCompare),
                typeof(StringKeyDeserializeCompare),
                typeof(NewVsOld),
                typeof(GuidImprov),
                typeof(ImproveStringKeySerializeBenchmark),
                typeof(MessagePackReaderBenchmark),
                typeof(MessagePackWriterBenchmark),
                typeof(SpanBenchmarks),
                typeof(Lz4Benchmark),
                typeof(Lz4PrimitiveBenchmark),
            });

            // args = new[] { "0" };
#if !DEBUG
            switcher.Run(args);
#else
            switcher.Run(args, new DebugInProcessConfig());
#endif
        }
Пример #2
0
        static void Main(string[] args)
        {
            var switcher = new BenchmarkSwitcher(new[] {
                typeof(FirstOrDefaultTypeBench),
                typeof(RelationBench),
                typeof(IsEvenBench),
                typeof(IteratorBench),
                typeof(PaginateBench),
                typeof(BinarySplitBench),
                typeof(TernarySplitBench),
                typeof(ListBench),
                typeof(FactorialBench),
                typeof(FibonacciBench),
                typeof(ToArrayVsToListBench),
                typeof(AggregateManyBench),
                typeof(PowerOfTwoBench),
                typeof(RangeDiffBench),
                typeof(InvalidateCollectionBench),
                typeof(JaggedVsRectArrayBench),
                typeof(DictionaryVsLookupBench),
                typeof(DoubleEnumerationBench),
                typeof(PullOutBench),
                typeof(ExceptBench),
                typeof(JoinBench),
                typeof(AggregateBench),
                typeof(EnumerableCreateBench),
                typeof(MemberAccessBench)
            });

            switcher.Run();
            Console.ReadLine();
        }
Пример #3
0
        // Run it with args = { "*" } for choosing all of target benchmarks
        private static void Main(string[] args)
        {
            var competitionSwitch = new BenchmarkSwitcher(new[]
            {
                typeof(BclTests.DateTimeBenchmarks),
                typeof(BclTests.DateTimeOffsetBenchmarks),
                typeof(BclTests.TimeZoneInfoBenchmarks),
                typeof(BclTests.UtcDateTimeBenchmarks),
                typeof(NodaTimeTests.Calendars.HebrewCalendarBenchmarks),
                typeof(NodaTimeTests.Calendars.IsoCalendarBenchmarks),
                typeof(NodaTimeTests.JsonNet.FormattingBenchmarks),
                typeof(NodaTimeTests.JsonNet.ParsingBenchmarks),
                typeof(NodaTimeTests.Text.InstantPatternBenchmarks),
                typeof(NodaTimeTests.Text.LocalDatePatternBenchmarks),
                typeof(NodaTimeTests.Text.LocalDateTimePatternBenchmarks),
                typeof(NodaTimeTests.Text.OffsetDateTimePatternBenchmarks),
                typeof(NodaTimeTests.Text.PeriodPatternBenchmarks),
                typeof(NodaTimeTests.Text.ZonedDateTimePatternBenchmarks),
                typeof(NodaTimeTests.BclDateTimeZoneBenchmarks),
                typeof(NodaTimeTests.CachedDateTimeZoneBenchmarks),
                typeof(NodaTimeTests.DurationBenchmarks),
                typeof(NodaTimeTests.InstantBenchmarks),
                typeof(NodaTimeTests.LocalDateBenchmarks),
                typeof(NodaTimeTests.LocalDateTimeBenchmarks),
                typeof(NodaTimeTests.LocalTimeBenchmarks),
                typeof(NodaTimeTests.OffsetBenchmarks),
                typeof(NodaTimeTests.OffsetDateTimeBenchmarks),
                typeof(NodaTimeTests.PacificZonedDateTimeBenchmarks),
                typeof(NodaTimeTests.PeriodBenchmarks),
                typeof(NodaTimeTests.StandardDaylightAlternatingMapBenchmarks),
                typeof(NodaTimeTests.UtcZonedDateTimeBenchmarks)
            });

            competitionSwitch.Run(args);
        }
        public static void Main(string[] args)
        {
            var switcher =
                new BenchmarkSwitcher(
                    new[]
            {
                typeof(DictionaryVsIDictionaryBenchmark),
                typeof(ListVsIEnumerableBenchmark),
                typeof(StringFormatBenchmark),
                typeof(RedundantTypeSpecificationBenchmark),
                typeof(StringAllocations),
                typeof(SimpleExtensionMethods),
                typeof(StringInterningBenchmark),
                typeof(StringInterningTrickBenchmark),
                typeof(StringSplitBenchmark),
                typeof(LinqWhereBenchmark),
                typeof(SimpleStringFormattingBenchmark),
                typeof(StringFormatterBenchmark),
                typeof(MethodInvocationOverheadBenchmark),
                typeof(UniValueGetValueBenchmark),
                typeof(MethodGroupExpressionBenchmark),
                typeof(CostOfIsSubclassOfBenchmark),
                typeof(StringEmptyBenchmark),
                typeof(InliningWithThrowBenchmark),
                typeof(HashSetVsUnsafeArrayLookupBenchmark),
                typeof(InstructionLevelParallelism),
                typeof(IsPrimeBenchmark),
                typeof(LoopVariableBenchmark),
                typeof(FalseSharingBenchmark)
            });

            switcher.Run(args);
        }
Пример #5
0
    static void Main(string[] args)
    {
        var switcher = new BenchmarkSwitcher(new[]
        {
            typeof(MapBenchmark),
        });

        args = new string[] { "0" };

#if DEBUG
        var _foo = Foo.New();
        var hee  = StandardResolver.Default.GetMapper <Foo, Foo>().Map(_foo, StandardResolver.Default);
        var heee = _foo.Adapt <Foo>();
        var foo2 = new List <int>()
        {
            1, 10, 100
        };
        var foo3 = ObjectMapper.DeepCopy(foo2);


        Console.WriteLine(foo3);
#else
        switcher.Run(args);
#endif
    }
Пример #6
0
        public static void Main(string[] args)
        {
            var switcher = new BenchmarkSwitcher(Benchmarks);

            switcher.Run(args);
            //switcher.Run(args, FastConfig);
        }
Пример #7
0
    static void Main(string[] args)
    {
        var switcher = new BenchmarkSwitcher(new[]
        {
            typeof(AssemblyVsDynamicMethod),
            typeof(SerializeCheck),
            typeof(DeserializeCheck),
            typeof(DoubleConvertBenchmark),
            typeof(StringToDoubleBenchmark),
            typeof(SwitchVsIf),
            typeof(SwitchVsSwitch),
        });

        //args = new string[] { "0" };

#if DEBUG
// {"Name":"foo"}
        JsonSerializer.ToJsonString(new MyPerson {
            Name = "foo", Addresses = new string[0]
        });

// {"Name":"bar","Addresses":["tokyo","kyoto"]}
        JsonSerializer.ToJsonString(new MyPerson {
            Name = "bar", Addresses = new[] { "tokyo", "kyoto" }
        });
#else
        switcher.Run(args);
#endif
    }
Пример #8
0
    static void Main(string[] args)
    {
        var switcher = new BenchmarkSwitcher(new[]
        {
            typeof(AssemblyVsDynamicMethod),
            typeof(SerializeCheck),
            typeof(DeserializeCheck),
            typeof(DoubleConvertBenchmark),
            typeof(StringToDoubleBenchmark),
            typeof(SwitchVsIf),
            typeof(SwitchVsSwitch),
        });

        //args = new string[] { "0" };

#if DEBUG
        //var p = new Person { Age = 99, Name = "foobar" };

        //// Object -> byte[] (UTF8)
        //byte[] result = JsonSerializer.Serialize(p);


        //// byte[] -> Object
        //var p2 = JsonSerializer.Deserialize<Person>(result);

        //// Object -> byte[]
        //var json = JsonSerializer.ToJsonString(p2);

        //// Write to Stream
        //JsonSerializer.Serialize(stream, p2);
#else
        switcher.Run(args);
#endif
    }
Пример #9
0
        static void Main(string[] args)
        {
            var switcher = new BenchmarkSwitcher(new[] {
                typeof(GenerationOperationsBenchmarks),
                typeof(EmptyBenchmarks),
                typeof(CountBenchmarks),
                typeof(CountPredicateBenchmarks),
                typeof(AllBenchmarks),
                typeof(AnyBenchmarks),
                typeof(AnyPredicateBenchmarks),
                typeof(ContainsBenchmarks),
                typeof(FirstBenchmarks),
                typeof(FirstOrDefaultBenchmarks),
                typeof(SingleBenchmarks),
                typeof(SingleOrDefaultBenchmarks),
                typeof(ToArrayBenchmarks),
                typeof(ToListBenchmarks),
                typeof(SelectBenchmarks),
                typeof(SelectCountBenchmarks),
                typeof(SelectToArrayBenchmarks),
                typeof(SelectToListBenchmarks),
                typeof(WhereBenchmarks),
                typeof(WhereCountBenchmarks),
                typeof(WhereFirstBenchmarks),
                typeof(WhereFirstOrDefaultBenchmarks),
                typeof(WhereSingleBenchmarks),
                typeof(WhereSingleOrDefaultBenchmarks),
                typeof(WhereToArrayBenchmarks),
                typeof(WhereToListBenchmarks),
                typeof(WhereSelectBenchmarks),
                typeof(WhereSelectCountBenchmarks),
            });

            switcher.Run(args);
        }
Пример #10
0
        static void Main(string[] args)
        {
            var assembly = System.Reflection.Assembly.GetExecutingAssembly();
            var switcher = new BenchmarkSwitcher(assembly);

            switcher.Run(args);
        }
Пример #11
0
        private static void Main()
        {
            Console.WriteLine("Effective Rx-version: " + typeof(Observable).Assembly.GetName().Version);

            var switcher = new BenchmarkSwitcher(new[] {
                typeof(ZipBenchmark),
                typeof(CombineLatestBenchmark),
                typeof(SwitchBenchmark),
                typeof(BufferCountBenchmark),
                typeof(RangeBenchmark),
                typeof(ToObservableBenchmark),
                typeof(RepeatBenchmark),
                typeof(ComparisonBenchmark),
                typeof(ComparisonAsyncBenchmark),
                typeof(ScalarScheduleBenchmark),
                typeof(StableCompositeDisposableBenchmark),
                typeof(SubjectBenchmark),
                typeof(ComparisonAsyncBenchmark)
#if (CURRENT)
                ,typeof(AppendPrependBenchmark)
#endif
            });

            switcher.Run();
            Console.ReadLine();
        }
Пример #12
0
        static void Main(string[] args)
        {
            if (args.Length > 0 && args[0] == "loop")
            {
                var benchmarks = new ComplexTypeBenchmarks();
                while (true)
                {
                    benchmarks.SerializeComplex();
                }
            }

            if (args.Length > 0 && args[0] == "structloop")
            {
                var benchmarks = new ComplexTypeBenchmarks();
                while (true)
                {
                    benchmarks.SerializeStruct();
                }
            }

            var switcher = new BenchmarkSwitcher(new[]
            {
                typeof(DeserializeBenchmark),
                typeof(SerializeBenchmark),
                typeof(StructSerializeBenchmark),
                typeof(StructDeserializeBenchmark),
                typeof(ComplexTypeBenchmarks)
            });

            switcher.Run(args);
        }
Пример #13
0
        public static void Main(string[] args)
        {
            var types = typeof(Program)
                        .Assembly
                        .GetExportedTypes()
                        .Where(r => r != typeof(Program) && r.IsPublic)
                        .OrderBy(r => r.Name);

            var job    = Job.Default;
            var config = new ManualConfig();

            config.AddLogger(DefaultConfig.Instance.GetLoggers().ToArray());
            config.AddExporter(DefaultConfig.Instance.GetExporters().ToArray());
            config.AddColumnProvider(DefaultConfig.Instance.GetColumnProviders().ToArray());
            config.AddValidator(JitOptimizationsValidator.DontFailOnError);
            //config.AddJob(job.WithRuntime(ClrRuntime.Net461));
            //config.AddJob(job.WithRuntime(CoreRuntime.Core21));
            //config.AddJob(job.WithRuntime(CoreRuntime.Core31));
            config.AddJob(job.WithRuntime(CoreRuntime.Core50));
            config.AddDiagnoser(MemoryDiagnoser.Default);
            config.AddColumn(StatisticColumn.OperationsPerSecond);
            config.AddColumn(RankColumn.Arabic);

            var switcher = new BenchmarkSwitcher(types.ToArray());

            switcher.Run(args, config);
        }
Пример #14
0
        static void Main(string[] args)
        {
            var switcher = new BenchmarkSwitcher(typeof(Program).Assembly);
            var config   = GetConfig(args);

            switcher.Run(new[] { "--filter", "*" }, config);
        }
Пример #15
0
        private static IEnumerable <Summary> RunAll()
        {
            var switcher  = new BenchmarkSwitcher(typeof(Program).Assembly);
            var summaries = switcher.Run(new[] { "*" });

            return(summaries);
        }
Пример #16
0
        public static void Main(string[] args)
        {
            var types    = Benchmarks.FindBenchmarks();
            var switcher = new BenchmarkSwitcher(types);

            switcher.Run(args);
        }
Пример #17
0
        private static IEnumerable <Summary> RunAll(IConfig config, string[] args)
        {
            var switcher  = new BenchmarkSwitcher(typeof(Program).Assembly);
            var summaries = switcher.Run(args, config);

            return(summaries);
        }
Пример #18
0
        private static void Main(string[] args)
        {
            // dotnet run -c Release -- --methods=ReadUtf8Char
            var switcher = new BenchmarkSwitcher(typeof(Program).Assembly);

            switcher.Run(args);
        }
Пример #19
0
        public int OnExecute()
        {
            try
            {
                using (var dynamicContext = new AssemblyResolver(Path.GetFullPath(AssemblyFile)))
                {
                    BenchmarkSwitcher benchmarkSwitcher = BenchmarkSwitcher.FromAssembly(dynamicContext.Assembly);
                    benchmarkSwitcher.Run(RemainingArguments);
                }
            }
            catch (FileLoadException ex)
            {
                Console.Error.WriteLine($"Couldn't load the assembly {AssemblyFile}.");
                Console.Error.WriteLine(ex.ToString());
                return(1);
            }
            catch (BadImageFormatException ex)
            {
                Console.Error.WriteLine($"The assembly {AssemblyFile} is not a valid assembly.");
                Console.Error.WriteLine(ex.ToString());
                return(1);
            }

            return(0);
        }
Пример #20
0
        private static void Main()
        {
            var benchmarksAssembly = typeof(Program).GetTypeInfo().Assembly;
            var benchmarkSwitcher  = new BenchmarkSwitcher(benchmarksAssembly);

            benchmarkSwitcher.Run();
        }
Пример #21
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Initiating benchmarking");

            var config = ManualConfig
                         .Create(DefaultConfig.Instance);

            // ensure numbers in csv do not have units
            var csvExporter = new CsvExporter(
                CsvSeparator.CurrentCulture,
                new SummaryStyle()
            {
                PrintUnitsInHeader  = true,
                PrintUnitsInContent = false,
                TimeUnit            = BenchmarkDotNet.Horology.TimeUnit.Millisecond,
            });

            config.Add(csvExporter);

            // I experimented with removing outliers but I think other processes on the system create outliers more
            // than abnormal data access patterns
            config.Add(
                Job.Default.WithRemoveOutliers(true));

            var switcher = new BenchmarkSwitcher(new[] { typeof(GetFileBenchmark), typeof(FileExistsBenchmark) });
            var summary  = switcher.Run(args, config);

            Console.WriteLine("Benchmarking complete");
        }
Пример #22
0
        public static void Main(string[] args)
        {
            var switcher = new BenchmarkSwitcher(new[] {
                typeof(AllTheThingsBenchmarks),
            });

            switcher.Run(args);
        }
Пример #23
0
        static void Main(string[] args)
        {
            BenchmarkSwitcher switcher = new BenchmarkSwitcher(new[] {
                typeof(FsContainerBenchmark)
            });

            switcher.Run();
        }
Пример #24
0
        static void Main(string[] args)
        {
            BenchmarkSwitcher switcher = new BenchmarkSwitcher(Assembly.GetCallingAssembly());

            switcher.Run(args);

            Console.ReadLine();
        }
Пример #25
0
        static void Main(string[] args)
        {
            var switcher = new BenchmarkSwitcher(new[] {
                typeof(QueryBenchmarks),
            });

            switcher.Run(args);
        }
Пример #26
0
        public static void Main(string[] args)
        {
            var switcher = new BenchmarkSwitcher(new[] {
                typeof(UrlPathToUrlPathTemplateMatcherBenchmarks),
            });

            switcher.Run(args);
        }
Пример #27
0
        static void Main(string[] args)
        {
            var competition = new BenchmarkSwitcher(new[] {
                typeof(CircularBufferBenchmarks),
            });

            competition.Run(args);
        }
Пример #28
0
        static void Main(string[] args)
        {
            var switcher = new BenchmarkSwitcher(new[] {
                typeof(PresentationPropertyBenchmark),
            });

            switcher.Run(args);
        }
        static void Main(string[] args)
        {
            var benchmarks =
                typeof(Program).GetTypeInfo().Assembly.ExportedTypes.Where(t => !t.GetTypeInfo().IsAbstract&& t.Name.EndsWith("Benchmark"));

            var switcher = new BenchmarkSwitcher(benchmarks.ToArray());

            switcher.Run(args, new BenchmarkConfig());
        }
Пример #30
0
        private static void Main(string[] args)
        {
            var switcher = new BenchmarkSwitcher(typeof(BenchmarkConfig).Assembly);

            //switcher.RunAll(new BenchmarkConfigWitRows());

            //For single run.
            switcher.Run(args, new BenchmarkConfigWitRows());
        }
Пример #31
0
 static void Main(string[] args)
 {
     // Use reflection for a more maintainable way of creating the benchmark switcher,
     // Benchmarks are listed in namespace order first (e.g. BenchmarkDotNet.Samples.CPU,
     // BenchmarkDotNet.Samples.IL, etc) then by name, so the output is easy to understand
     var benchmarks = Assembly.GetExecutingAssembly().GetTypes()
         .Where(t => t.GetMethods(BindingFlags.Instance | BindingFlags.Public)
                      .Any(m => m.GetCustomAttributes(typeof(BenchmarkAttribute), false).Any()))
         .OrderBy(t => t.Namespace)
         .ThenBy(t => t.Name)
         .ToArray();
     var competitionSwitch = new BenchmarkSwitcher(benchmarks);
     competitionSwitch.Run(args);
 }