public static void Demo_2(long n) { using (LiteProfilerAgent agent = new LiteProfilerAgent()) { long heavy = TimeConsuming.HeavyCalculation(n); Console.WriteLine($"Heavy Calculation({n}) = {heavy}"); } }
public static void Demo_3(long n) { LiteProfiler.Reset(filterClasses: true); using (LiteProfilerAgent agent = new LiteProfilerAgent()) { long heavy = TimeConsuming.HeavyCalculation(n); Console.WriteLine($"Heavy Calculation({n}) = {heavy}"); } Console.Write(LiteProfiler.GetReport().PrettyPrint()); }
public static long OneStep(long i) { using (LiteProfilerAgent agent = new LiteProfilerAgent()) { long c = random.Next(1, Max); long result = ((i * c) % Max) + 1; Console.SetCursorPosition(0, 0); Console.WriteLine($"(({i} * {c}) % {Max}) + 1 = {result}"); Console.WriteLine(LiteProfiler.GetQuote($"step starts with i = {i}").PrettyPrint()); return result; } }
public static void Demo_1(long n) { using (LiteProfilerAgent agent = new LiteProfilerAgent()) { long prime = PrimeNumbers.Find(n); Console.SetCursorPosition(0, 2); Console.WriteLine($"Prime #{n} = {prime}"); } Console.Write(LiteProfiler.GetReport().PrettyPrint()); NextDemo(); }
public static long HeavyCalculation(long n) { using (LiteProfilerAgent agent = new LiteProfilerAgent()) { long result = 1; for (long i = 0; i < n; ++i) { result = OneStep(result); } return result; } }
public static bool IsPrime(long i) { using (LiteProfilerAgent agent = new LiteProfilerAgent()) { long b = 2; while (b * b <= i) { if (i % b == 0) { return(false); } b++; } return(true); } }
static void Main(string[] args) { LiteProfiler.Reset(); LiteProfiler.SuspiciousClasses = new HashSet <string>(File.ReadAllLines((args.Length > 0) ? args[0] : "classes.txt")); Console.WriteLine($"n = {n}"); using (LiteProfilerAgent agent = new LiteProfilerAgent()) { Demo_1(n); Demo_2(n); } Console.Write(LiteProfiler.GetReport().PrettyPrint()); NextDemo(); Demo_3(n); Console.ReadKey(); }
public static long Find(long n) { using (LiteProfilerAgent agent = new LiteProfilerAgent()) { long count = 0; long a = 2; while (count < n) { if (IsPrime(a)) { count++; Console.SetCursorPosition(0, 1); Console.WriteLine($"prime #{count} / {n} = {a}"); } a++; } return(--a); } }