public static void RecordThreadExecutionTimes() { StringBuilder results = new StringBuilder(); Stopwatch stopwatch = new Stopwatch(); for (int i = 1; i <= N_TRIALS; i++) { Console.WriteLine(i); for (int j = 1; j <= 8; j++) { ThreadPool.SetMinThreads(8, 8); ThreadPool.SetMaxThreads(8, 8); var m = new MarkovChain(AllocateMatrix(500)); ThreadPool.SetMinThreads(j, j); ThreadPool.SetMaxThreads(j, j); stopwatch.Start(); m.SteadyStateValues(); stopwatch.Stop(); ThreadPool.SetMinThreads(8, 8); ThreadPool.SetMaxThreads(8, 8); results.Append($"{stopwatch.ElapsedTicks}, "); stopwatch.Reset(); } results.AppendLine(""); } results.Write("ParallelThreadTimes.csv"); }
public static void RecordExecutionTimes() { StringBuilder results = new StringBuilder(); Stopwatch stopwatch = new Stopwatch(); for (int i = 0; i < N_TRIALS; i++) { Console.WriteLine(i); for (int j = 3; j <= MAX_MATRIX_SIZE; j++) { var m = new MarkovChain(AllocateMatrix(j)); stopwatch.Start(); m.SteadyStateValues(); stopwatch.Stop(); results.Append($"{stopwatch.ElapsedTicks}, "); stopwatch.Reset(); } results.AppendLine(""); } results.Write("BruteForceMedianExecutionTimeResults.csv"); }
static void Main(string[] args) //TODO: write code to get a proper average execution time { double[,] mchain = { { 0.65, 0.15, 0.1 }, { 0.25, 0.65, 0.4 }, { 0.1, 0.2, 0.5 }, }; MarkovChain m = new MarkovChain(mchain); Console.WriteLine(m); var solved = m.SteadyStateValues(); foreach (var s in solved) { Console.WriteLine($"pi_{s.Pi} = {s.Value}"); } var randomMatrix = AllocateMatrix(N); var m2 = new MarkovChain(randomMatrix); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); var solved2 = m2.SteadyStateValues(); stopwatch.Stop(); Console.WriteLine(stopwatch.ElapsedMilliseconds); //RecordExecutionTimes(); //RecordThreadExecutionTimes(); Thread.Sleep(1000); Console.ReadLine(); }