private static void MeasureTests() { var tests = new ProjectTreeTests(new LogHelper()); RootedProjectTree templateTree = ProjectTreeTests.ConstructVeryLargeTree(new Random(21748171), 4, 100, 10000); Console.WriteLine("Template tree contains {0} nodes.", templateTree.GetSelfAndDescendents().Count()); MeasureReport(tests.CloneProjectTreeLeafToRoot, templateTree, "Optimal clone"); MeasureReport(tests.CloneProjectTreeRootToLeafWithBuilders, templateTree, "Sub-optimal (using builders)"); MeasureReport(tests.CloneProjectTreeRootToLeafWithoutBuilders, templateTree, "Sub-optimal"); }
private static void MeasureReport(Func<RootedProjectTree, RootedProjectTree> action, RootedProjectTree templateTree, string name) { GC.Collect(); var timer = Stopwatch.StartNew(); var result = action(templateTree); timer.Stop(); if (result.GetSelfAndDescendents().Count() != templateTree.GetSelfAndDescendents().Count()) { Console.WriteLine("FAIL: invalid clone"); } Console.WriteLine("{0} {1}", timer.Elapsed, name); }
private static void MeasureReport(Func <RootedProjectTree, RootedProjectTree> action, RootedProjectTree templateTree, string name) { GC.Collect(); var timer = Stopwatch.StartNew(); var result = action(templateTree); timer.Stop(); if (result.GetSelfAndDescendents().Count() != templateTree.GetSelfAndDescendents().Count()) { Console.WriteLine("FAIL: invalid clone"); } Console.WriteLine("{0} {1}", timer.Elapsed, name); }