Example #1
0
        public static void Main()
        {
            if (false)
            {
                var benchmark = Gu.Roslyn.Asserts.Benchmark.Create(Code.ValidCodeProject, new CreationAnalyzer());

                // Warmup
                benchmark.Run();
                Console.WriteLine("Attach profiler and press any key to continue...");
                Console.ReadKey();
                using (SyntaxTreeCache <SemanticModel> .Begin(null))
                {
                    benchmark.Run();
                }
            }
            else if (false)
            {
                var benchmark = Gu.Roslyn.Asserts.Benchmark.Create(Code.ValidCodeProject, new CreationAnalyzer());
                //// Warmup
                benchmark.Run();
                var sw = Stopwatch.StartNew();
                ////Cache<Microsoft.CodeAnalysis.SyntaxTree, Microsoft.CodeAnalysis.SemanticModel>.Begin();
                benchmark.Run();
                sw.Stop();
                ////Cache<Microsoft.CodeAnalysis.SyntaxTree, Microsoft.CodeAnalysis.SemanticModel>.End();
                Console.WriteLine($"Took: {sw.Elapsed.TotalMilliseconds:F3} ms");
                Console.WriteLine("Press any key to exit...");
                Console.ReadKey();
            }
            else
            {
                using (SyntaxTreeCache <SemanticModel> .Begin(null))
                {
                    foreach (var summary in RunAll())
                    {
                        CopyResult(summary);
                    }
                }
            }
        }
 public static void OneTimeSetUp()
 {
     // The cache will be enabled when running in VS.
     // It speeds up the tests and makes them more realistic
     cacheTransaction = SyntaxTreeCache <SemanticModel> .Begin(null);
 }