class Program { public const int Iterations = 1000000; static void Main(string[] args) { Console.WriteLine("Testing Manual Wireup Event Handler Performance with {0:#,0} iterations", Iterations); // Dry run so that the code is JITed before we test. RunTest("Dry Run"); List<Account> accounts = new List<Account>(Iterations); Stopwatch watch = new Stopwatch(); watch.Start(); for (int i = 0; i < Iterations; i++) accounts.Add(RunTest(string.Format("Account {0}", i))); watch.Stop(); Console.WriteLine("Completed {0:#,0} iterations in {1:#,0} ms", Iterations, watch.ElapsedMilliseconds); Console.WriteLine("Average Time is {0:#,0} ms or {1:#,0} ticks", watch.ElapsedMilliseconds / (double)Iterations, watch.ElapsedTicks / (double)Iterations); Console.WriteLine("\nPress enter to exit"); Console.ReadLine(); } private static Account RunTest(string accountName) { IEventProvider<IDomainEvent> account = new Account(); account.LoadFromHistory(new IDomainEvent[] { new AccountCreatedEvent(accountName), new DepositEvent(1000), new WithdrawEvent(300), new WithdrawEvent(250), new DepositEvent(35.90M), new WithdrawEvent(10.80M) }); return account as Account; } }