private static void ExecuteWithNew(string[] args) { Stopwatch watch = new Stopwatch(); ICommentRepo repo = new ComplementaryRepo(); using (var writer = new StreamWriter(new MemoryStream())) { watch.Start(); for (int i = 0; i < iterations; i++) { // Note that this would be a singleton in Autofac. As singletons are difficult and dangerous without autfac, I'll create one each time. //ICommentRepo repo = new ComplementaryRepo(); new ClassForDemonstratingDelegateFactories(repo, "Whatever ").Print(writer); } } Console.WriteLine("Execution time {0}. Iterations per ms {1}", watch.Elapsed, watch.Elapsed.Milliseconds == 0 ? 0 : iterations / watch.Elapsed.Milliseconds); }
private static void ExecuteWithNew(string[] args) { Stopwatch watch = new Stopwatch(); ICommentRepo repo = new ComplementaryRepo(); using (var writer = new StreamWriter(new MemoryStream())) { watch.Start(); for (int i = 0; i < iterations; i++) { // Note that this would be a singleton in Autofac. As singletons are difficult and dangerous without autfac, I'll create one each time. //ICommentRepo repo = new ComplementaryRepo(); new ClassForDemonstratingDelegateFactories(repo, "Whatever ").Print(writer); } } Console.WriteLine("Execution time {0}. Iterations per ms {1}", watch.Elapsed, watch.Elapsed.Milliseconds == 0 ? 0 : iterations / watch.Elapsed.Milliseconds); }