protected override async Task <int> Execute() { var useClients = ClientsArg.HasValue() ? int.Parse(ClientsArg.Value()) : 10; var useRuns = RunsArg.HasValue() ? int.Parse(RunsArg.Value()) : 100; var useQuery = string.IsNullOrWhiteSpace(QueryArg.Value) ? string.Empty : QueryArg.Value; var lookup = GetDnsLookup(); var settings = GetLookupSettings(); var runner = new PerfRunner(settings, useClients, useRuns, useQuery); await runner.Run(); return(0); }
static void Main(string[] args) { var source = new Contact(); var target = new ContactDataContract(); var mooMapper = MappingRepository.Default.ResolveMapper <Contact, ContactDataContract>(); AutoMapper.Mapper.CreateMap <Contact, ContactDataContract>(); var actions = new [] { new Tuple <string, Action>("Manual code", () => ManualMap(source, target)), new Tuple <string, Action>("ManualErrorHandlingMap", () => ManualErrorHandlingMap(source, target)), new Tuple <string, Action>("Lambda map", () => LambdaMap(source, target)), new Tuple <string, Action>("Expression map", () => ExpressionMap(source, target)), new Tuple <string, Action>("Reflection map", () => ReflectionMap(source, target)), new Tuple <string, Action>("Moo (w/ repo)", () => mooMapper.Map(source, target)), new Tuple <string, Action>("Automapper (default use)", () => AutoMapper.Mapper.Map <Contact, ContactDataContract>(source, target)), }; var perfRunner = new PerfRunner(actions); foreach (var r in perfRunner.Run()) { Console.WriteLine( "Results for {0} ({1} repeats)", r.Item1, r.Item2.RepeatCount); Console.WriteLine(" Average ticks: {0}", r.Item2.OverallAverageTicks); Console.WriteLine(" Max ticks: {0}", r.Item2.OverallMaxTicks); Console.WriteLine(" Min ticks: {0}", r.Item2.OverallMinTicks); Console.WriteLine(); } }
static void Main(string[] args) { PerfRunner.Run(); }
async Task RunPerfAsync() { await Task.Delay(500); await PerfRunner.RunAsync(); }