Esempio n. 1
0
 private static void TestOmegas()
 {
     Print(OmegaCalculator.CalculateOmegasRowBasic(32), true);
     Console.WriteLine();
     Print(OmegaCalculator.CalculateOmegasRowOptimised(32), true);
     for (int n = 2; n < 12; n++)
     {
         int k = (int)Math.Pow(2, n);
         stopwatch.Restart();
         for (int i = 0; i < 1000; i++)
         {
             OmegaCalculator.CalculateOmegasRowBasic(k);
         }
         stopwatch.Stop();
         t1 = stopwatch.ElapsedMilliseconds;
         t2 = stopwatch.ElapsedTicks;
         stopwatch.Restart();
         for (int i = 0; i < 1000; i++)
         {
             OmegaCalculator.CalculateOmegasRowOptimised(k);
         }
         stopwatch.Stop();
         t3 = stopwatch.ElapsedMilliseconds;
         t4 = stopwatch.ElapsedTicks;
         Console.WriteLine($"{k,4} {t1,6} {t2,10} {t3,6} {t4,10} {t2 / t4}");
         //Console.WriteLine($"n = {k}\nBasic: {t1}ms\nOptimised: {t3}ms\nSpeedup: {t2 / t4}x");
     }
 }