Beispiel #1
0
        public string WeatherDataListing()
        {
            //Forms the weather data into a string separated by line feeds
            string wsList = "";

            if (weaList.Count > 0)
            {
                {
                    wsList += "WriteDate:\t" + ReportDate.ToString("hh:mm:ss");
                    wsList += "\r\n" + "TempScale:\t" + TempScale.ToString();
                    wsList += "\r\n" + "WindScale:\t" + WindScale.ToString();
                    wsList += "\r\n" + "SkyTemp:\t" + SkyTemp.ToString();
                    wsList += "\r\n" + "AmbTemp:\t" + AmbTemp.ToString();
                    wsList += "\r\n" + "SenTemp:\t" + SenTemp.ToString();
                    wsList += "\r\n" + "WindSpeed:\t" + WindSpeed.ToString();
                    wsList += "\r\n" + "Humidity:\t\t" + Humidity.ToString();
                    wsList += "\r\n" + "DewPoint:\t" + DewPoint.ToString();
                    wsList += "\r\n" + "DewHeat:\t" + DewHeat.ToString();
                    wsList += "\r\n" + "RainFlag:\t\t" + RainFlag.ToString();
                    wsList += "\r\n" + "WetFlag:\t\t" + WetFlag.ToString();
                    wsList += "\r\n" + "ElapsedTime:\t" + ElapsedSeconds.ToString();
                    wsList += "\r\n" + "LastDataWrite:\t" + LastDataWrite.ToString("hh:mm:ss");
                    wsList += "\r\n" + "Cloudiness:\t" + Cloudiness.ToString();
                    wsList += "\r\n" + "Windiness:\t" + Windiness.ToString();
                    wsList += "\r\n" + "Raininess:\t" + Raininess.ToString();
                    wsList += "\r\n" + "Darkness:\t" + Darkness.ToString();
                    wsList += "\r\n" + "RoofCloseFlag:\t" + RoofCloseFlag.ToString();
                    wsList += "\r\n" + "AlertFlag:\t\t" + AlertFlag.ToString();
                }
            }
            return(wsList);
        }
Beispiel #2
0
        static void BinaryMaxTim(int[] TestVector)
        {
            double ElapsedSeconds;
            long   ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;

            for (int n = 0; n < (NIter + 1 + 1); ++n)
            {
                long StartingTime = Stopwatch.GetTimestamp();
                bool Present      = IsPresent_BinaryTim(TestVector, TestVector[TestVector.Length - 1]);
                long EndingTime   = Stopwatch.GetTimestamp();
                IterationElapsedTime = EndingTime - StartingTime;
                ElapsedTime         += IterationElapsedTime;
                if (IterationElapsedTime < MinTime)
                {
                    MinTime = IterationElapsedTime;
                }
                if (IterationElapsedTime > MaxTime)
                {
                    MaxTime = IterationElapsedTime;
                }
            }
            ElapsedTime   -= (MinTime + MaxTime);
            ElapsedSeconds = ElapsedTime * (1.0 / (NIter * Stopwatch.Frequency));

            data.Add(ElapsedSeconds.ToString("F10"));

            Console.WriteLine("Binary Max Tim " + ElapsedSeconds.ToString("F10"));
        }
Beispiel #3
0
        static void PrimeOptimalTime(ulong n)
        {
            decimal ElapsedSeconds;
            long    ElapsedTime = 0;
            long    MinTime     = long.MaxValue;
            long    MaxTime     = long.MinValue;
            long    IterationElapsedTime;

            for (int i = 0; i < TimeIterationAmount + 2; i++)
            {
                long StartingTime = Stopwatch.GetTimestamp();     //Czas startowy iteracji
                PrimeOptimal(n);
                long EndingTime = Stopwatch.GetTimestamp();       //Czas końcowy iteracji
                IterationElapsedTime = EndingTime - StartingTime; //Czas trwania iteracji
                ElapsedTime         += IterationElapsedTime;      //Dodanie czasu iteracji do czasu łącznego
                if (IterationElapsedTime < MinTime)
                {
                    MinTime = IterationElapsedTime;                                 //Jeśli czas iteracji jest krótszy od dotychczasowego najkrótszego czasu ustawienie go jako nowego najkrótszego czasu
                }
                if (IterationElapsedTime > MaxTime)
                {
                    MaxTime = IterationElapsedTime;                                 //Jeśli czas iteracji jest dłuższy od dotychczasowego najdłuższego czasu ustawienie go jako nowego najdłuższego czasu
                }
            }
            ElapsedTime   -= (MinTime + MaxTime);                                                          //Odjęcie czasu najkrótszej i najdłuższej iteracji
            ElapsedSeconds = (decimal)(ElapsedTime * (1.0 / (TimeIterationAmount * Stopwatch.Frequency))); //Podzielenie przez liczbę iteracji pomnożoną przez częstotliwość zegara
            OutputFile.Write(ElapsedSeconds.ToString() + ";");
        }
Beispiel #4
0
            static void LinearMaxTim()
            {
                double ElapsedSeconds;
                long   ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;

                for (int n = 0; n < (NIter + 1 + 1); ++n)
                {
                    long StartingTime = Stopwatch.GetTimestamp();
                    bool Present      = IsPresent_LinearTim(TestVector, TestVector.Length - 1);
                    long EndingTime   = Stopwatch.GetTimestamp();
                    IterationElapsedTime = EndingTime - StartingTime;
                    ElapsedTime         += IterationElapsedTime;
                    if (IterationElapsedTime < MinTime)
                    {
                        MinTime = IterationElapsedTime;
                    }
                    if (IterationElapsedTime > MaxTime)
                    {
                        MaxTime = IterationElapsedTime;
                    }
                }
                ElapsedTime   -= (MinTime + MaxTime);
                ElapsedSeconds = (ElapsedTime * (1.0 / (NIter * Stopwatch.Frequency))) * 1000;
                Console.Write("\t" + ElapsedSeconds.ToString("F4") + " ms");
            }
Beispiel #5
0
 public override string ToString()
 {
     if (String.IsNullOrWhiteSpace(Detail))
     {
         return(String.Format("{0}: {1}", Event, ElapsedSeconds.ToString("0.00")));
     }
     else
     {
         return(String.Format("{0} - {1}: {2}", Event, Detail, ElapsedSeconds.ToString("0.00")));
     }
 }
Beispiel #6
0
        static void Main(string[] args)
        {
            Random random = new Random();

            int    result      = 0; //zmienna ktora przechowuje index liczby znalezionej
            long   min         = long.MaxValue;
            long   max         = long.MinValue;
            long   timeElapsed = 0;
            long   iterTimeElapsed;
            double ElapsedSeconds;

            Console.WriteLine("size;lookupvalue;result;time;oper_count");
            for (int i = 26843545; i <= 268435450; i += 26843545)
            {
                int[] tab = new int[i];
                for (int k = 0; k < tab.Length; k++)
                {
                    tab[k] = k + 1;
                }
                Array.Sort(tab);              // sortowanie tablicy rozsnąco
                int lookUpValue = tab.Length; // wartość szukana
                for (int j = 0; j < iter + 2; ++j)
                {
                    long start = Stopwatch.GetTimestamp();   // start czasu
                    result = SimpleSearch(tab, lookUpValue); // pomiar czasu dla liniowego tutaj robimy bez instrumentacji
                    long stop = Stopwatch.GetTimestamp();    // stop czas
                    iterTimeElapsed = stop - start;
                    timeElapsed    += iterTimeElapsed;
                    if (iterTimeElapsed < min)
                    {
                        min = iterTimeElapsed;
                    }
                    if (iterTimeElapsed > max)
                    {
                        max = iterTimeElapsed;
                    }
                    result      = SimpleSearchOptions(tab, lookUpValue); // wynik instrumentacji
                    timeElapsed = (min + max);
                }
                long wynik = suma / counter;
                ElapsedSeconds = timeElapsed * (1.0 / (iter * Stopwatch.Frequency));
                Console.WriteLine(i + ";" + lookUpValue + ";" + result + ";" + (ElapsedSeconds.ToString("F4")) + ";" + wynik); // tablica; szukana; index; czas; za którym razem
            }
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            Console.WriteLine("size;lookupvalue;result;time;oper_count");
            int    result      = 0;
            long   min         = long.MaxValue;
            long   max         = long.MinValue;
            long   timeElapsed = 0;
            long   iterTimeElapsed;
            int    lookUpValue;
            double ElapsedSeconds;

            //for (int i = 2000000; i < Math.Pow(2, 28); i += 100000)
            for (int i = 26843545; i <= 268435450; i += 26843545)
            {
                int[] tab = new int[i];
                for (int k = 0; k < tab.Length; k++)
                {
                    tab[k] = k + 1;
                }
                Array.Sort(tab);                // sortowanie tablicy rozsnąco
                lookUpValue = (tab.Length + 2); // wartość szukana
                for (int j = 0; j < iter + 2; ++j)
                {
                    long start = Stopwatch.GetTimestamp();             // start czasu
                    result = BinarySearchPesymistic(tab, lookUpValue); // pomiar czasu dla binarnego tutaj robimy bez instrumentacji
                    long stop = Stopwatch.GetTimestamp();              // stop czas
                    iterTimeElapsed = stop - start;
                    timeElapsed    += iterTimeElapsed;
                    if (iterTimeElapsed < min)
                    {
                        min = iterTimeElapsed;
                    }
                    if (iterTimeElapsed > max)
                    {
                        max = iterTimeElapsed;
                    }
                    result = BinarySearchPesymisticOptions(tab, lookUpValue); // wynik instrumentacji
                }
                timeElapsed    = (min + max);
                ElapsedSeconds = timeElapsed * (1.0 / (iter * Stopwatch.Frequency));
                Console.WriteLine(i + ";" + lookUpValue + ";" + result + ";" + (ElapsedSeconds.ToString("F0")) + ";" + counter); // tablica; szukana; index; czas; za którym razem
            }
        }
            static void BinaryAvgTim()
            {
                double ElapsedSeconds;
                long   ElapsedTime = 0, IterationElapsedTime, Avg = 0;

                for (int n = 0; n < (NIter + 1 + 1); ++n)
                {
                    long StartingTime = Stopwatch.GetTimestamp();
                    bool Present      = IsPresent_BinaryTim(TestVector, TestVector.Length);
                    long EndingTime   = Stopwatch.GetTimestamp();
                    IterationElapsedTime = EndingTime - StartingTime;
                    ElapsedTime         += IterationElapsedTime;
                    if (n > 0)
                    {
                        Avg = ElapsedTime / n;
                    }
                }
                ElapsedSeconds = Avg * (1.0 / (NIter * Stopwatch.Frequency));
                Console.Write("\t" + ElapsedSeconds.ToString("F8"));
            }
Beispiel #9
0
 static void Main(string[] args)
 {
     Random random = new Random();
     int lookUpValue = 1001; // wartość szukana
     long min = long.MaxValue;
     long max = long.MinValue;
     long timeElapsed = 0;
     long iterTimeElapsed;
     
     double ElapsedSeconds;
     int result = 0;
     //Generate tables with random value
     Console.WriteLine("size;lookupvalue;result;time;oper_count");
     //for (int i = 2000000; i < Math.Pow(2,28); i += 100000)
     for (int i = 26843545; i <= 268435450; i += 26843545)
     {
         int[] tab = new int[i];
         for (int k = 0; k < tab.Length; k++)
         {
             tab[k] = random.Next(1, 1000);
         }
         Array.Sort(tab);
         for (int j = 0; j < iter + 2; ++j)
         {
             long start = Stopwatch.GetTimestamp(); // start czasu
             result = SimpleSearch(tab, lookUpValue); // pomiar czasu dla liniowego tutaj robimy bez instrumentacji
             long stop = Stopwatch.GetTimestamp();   // stop czas
             iterTimeElapsed = stop - start;
             timeElapsed += iterTimeElapsed;
             if (iterTimeElapsed < min) min = iterTimeElapsed;
             if (iterTimeElapsed > max) max = iterTimeElapsed;
             
             result = SimpleSearchOptions(tab, lookUpValue); // wynik instrumentacji
             timeElapsed = (min + max);
         }
         ElapsedSeconds = timeElapsed * (1.0 / (iter * Stopwatch.Frequency));
         Console.WriteLine(i + ";" + lookUpValue + ";" + result + ";" + (ElapsedSeconds.ToString("F4")) + ";" + counter); // tablica; szukana; index; czas; za którym razem
     }
 }
Beispiel #10
0
        static void Main(string[] args)
        {
            int    indeks      = 0;
            long   TimeElapsed = 0;
            long   iterTimeElapsed;
            double ElapsedSeconds;

            Console.WriteLine("nr;rozmiar;szukana;nr indeksu;ilosc operacji;czas;zlozonosc");
            int nr = 0;

            for (int j = 5368709; j <= 268435450; j += 5368709)//maksymalna wielkość tablicy to 2 do potegi 28, zwiększa się tak by uzyskać 50 pomiarów.
            {
                int[] table = new int[j];
                for (int i = 0; i < table.Length; i++)
                {
                    table[i] = i + 1;
                }
                for (int i = 0; i < iter + 2; i++)
                {
                    szukana = table.Length / 2;
                    long start = Stopwatch.GetTimestamp();                                //stoper start
                    indeks = wyszukiwanieliniowe(table, szukana);                         //liniowe bez instrumentacji
                    long stop = Stopwatch.GetTimestamp();                                 //stoper stop
                    iterTimeElapsed = stop - start;                                       //za pomocą róznicy obliczamy czas
                    TimeElapsed     = iterTimeElapsed;
                    indeks          = wyszukiwanieliniowepoinstumentacji(table, szukana); //liniowe z instumentacją
                }
                long wynik = suma / licznik;                                              //zlozonosc
                ElapsedSeconds = TimeElapsed * (1.0 / (iter * Stopwatch.Frequency));
                Console.WriteLine(++nr + "; " + j + ";" + szukana + ";" + indeks + ";" + licznik + ":" + (ElapsedSeconds.ToString("F4")) + ";" + wynik);
            }
            Console.ReadKey();
        }
        static void Main()
        {
            int    indeks      = 0;//indeks w którym znajduje się szukana
            long   TimeElapsed = 0;
            long   iterTimeElapsed;
            int    szukana;
            double ElapsedSeconds;

            Console.WriteLine("nr;rozmiar;szukana;indeks;ilosc operacji;czas;zlozonosc");
            for (int j = 5368709; j <= 268435450; j += 5368709)//maksymalny rozmiar tablicy to 2 do potegi 28, 50 punktow pomiarowych
            {
                ++nr;
                int[] table = new int[j];
                for (int i = 0; i < table.Length; i++)
                {
                    table[i] = i + 1;
                }
                szukana = table.Length - 1;
                Array.Sort(table);
                for (int i = 0; i < iter + 2; ++i)
                {
                    long start = Stopwatch.GetTimestamp();                                 //stoper start
                    indeks = Binarne(table, szukana, table.Length);                        //bez instrumentacji
                    long stop = Stopwatch.GetTimestamp();                                  //stoper stop
                    iterTimeElapsed = stop - start;                                        //czas obliczamy za pomoca roznicy
                    TimeElapsed    += iterTimeElapsed;
                    indeks          = Binarneinstrumentacja(table, szukana, table.Length); //z instrumentacja
                }
                ElapsedSeconds = TimeElapsed * (1.0 / (iter * Stopwatch.Frequency));
                Console.WriteLine(nr + ";" + j + ";" + szukana + ";" + indeks + ";" + licznik + ";" + (ElapsedSeconds.ToString("F4")) + ";" + wynik);
            }
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            int    indeks      = 0;
            long   TimeElapsed = 0;
            long   iterTimeElapsed;
            double ElapsedSeconds;

            Console.WriteLine("nr;rozmiar;szukana;nr indeksu;ilosc operacji;czas");
            int nr = 0;

            for (int j = 5368709; j <= 268435450; j += 5368709)//maksymalny rozmiar tablicy to 2 do potegi 28, program wykonuje 50 pomiarow
            {
                int[] table = new int[j];
                szukana = table.Length + 1;
                for (int i = 0; i < table.Length; i++)
                {
                    table[i] = i + 1;
                }
                for (int i = 0; i < iter + 2; i++)
                {
                    long start = Stopwatch.GetTimestamp();                                //stoper start
                    indeks = wyszukiwanieliniowe(table, szukana);                         //wyszukiwanie bez instrumentacji
                    long stop = Stopwatch.GetTimestamp();                                 //stoper stop
                    iterTimeElapsed = stop - start;                                       //czas obliczamy poprzez roznice
                    TimeElapsed     = iterTimeElapsed;
                    indeks          = wyszukiwanieliniowepoinstumentacji(table, szukana); //z instrumentacja
                }
                ElapsedSeconds = TimeElapsed * (1.0 / (iter * Stopwatch.Frequency));
                Console.WriteLine(++nr + "; " + j + ";" + szukana + ";" + indeks + ";" + licznik + ":" + (ElapsedSeconds.ToString("F4")));
            }
            Console.ReadKey();
        }
        static void Main(String[] args)
        {
            int    indeks      = 0;//indeks w ktorym znajduje sie szukana liczba
            long   TimeElapsed = 0;
            long   iterTimeElapsed;
            int    szukana;//szukana liczba
            double ElapsedSeconds;

            Console.WriteLine("nr;rozmiar;szukana;indeks;ilosc operacji;czas;");
            for (int j = 5368709; j < 268435450; j += 5368709)
            {
                ++nr;
                int[] table = new int[j];
                for (int i = 0; i < table.Length; i++)
                {
                    table[i] = i + 1;
                }
                szukana = table.Length + 1;
                Array.Sort(table);
                for (int i = 0; i < iter + 2; ++i)
                {
                    long start = Stopwatch.GetTimestamp();                                 //stoper start
                    indeks = Binarne(table, szukana, table.Length);                        //wyszukiwane z instrumentacja
                    long stop = Stopwatch.GetTimestamp();                                  //stoper stop
                    iterTimeElapsed = stop - start;                                        //czas obliczamy za pomoca roznicy
                    TimeElapsed    += iterTimeElapsed;
                    indeks          = Binarneinstrumentacja(table, szukana, table.Length); //wyszukiwane z instrumentacja
                }
                ElapsedSeconds = TimeElapsed * (1.0 / (iter * Stopwatch.Frequency));
                Console.WriteLine(nr + ";" + j + ";" + szukana + ";" + indeks + ";" + licznik + ";" + (ElapsedSeconds.ToString("F4")));
            }
            Console.ReadKey();
        }
Beispiel #14
0
        } /* qsort() */

        static void Main(string[] args)
        {
            const int NIter = 10; // Liczba powtórzeń testu.

            // I
            // Tablica generowna losowo.
            Random rnd = new Random(Guid.NewGuid().GetHashCode());

            int[] ArrayRandom = new int[200000];
            for (int j = 0; j < ArrayRandom.Length; j++)
            {
                ArrayRandom[j] = rnd.Next(int.MaxValue);
            }

            Console.WriteLine("\nInsertionSort [tablica generowana losowo]\nARRAY SIZE:\t TIME [ms]:");
            for (int u = 50000; u <= 200000; u += 10000)
            {
                int[] TestArray = new int[u];
                Array.Copy(ArrayRandom, TestArray, u);
                double ElapsedSeconds;
                long   ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;
                for (int n = 0; n < (NIter + 1 + 1); ++n)  // odejmujemy wartości skrajne
                {
                    long StartingTime = Stopwatch.GetTimestamp();
                    InsertionSort(TestArray);
                    long EndingTime = Stopwatch.GetTimestamp();
                    IterationElapsedTime = EndingTime - StartingTime;
                    ElapsedTime         += IterationElapsedTime;
                    if (IterationElapsedTime < MinTime)
                    {
                        MinTime = IterationElapsedTime;
                    }
                    if (IterationElapsedTime > MaxTime)
                    {
                        MaxTime = IterationElapsedTime;
                    }
                }
                ElapsedTime   -= (MinTime + MaxTime);
                ElapsedSeconds = ElapsedTime * (1000.0 / (NIter * Stopwatch.Frequency));
                Console.WriteLine("{0,-12}\t{1}", u, ElapsedSeconds.ToString("F4"));
            }

            Console.WriteLine("\nSelectionSort [tablica generowana losowo]\nARRAY SIZE:\t TIME [ms]:");
            for (int u = 50000; u <= 200000; u += 10000)
            {
                int[] TestArray = new int[u];
                Array.Copy(ArrayRandom, TestArray, u);

                double ElapsedSeconds;
                long   ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;
                for (int n = 0; n < (NIter + 1 + 1); ++n)  // odejmujemy wartości skrajne
                {
                    long StartingTime = Stopwatch.GetTimestamp();
                    SelectionSort(TestArray);
                    long EndingTime = Stopwatch.GetTimestamp();
                    IterationElapsedTime = EndingTime - StartingTime;
                    ElapsedTime         += IterationElapsedTime;
                    if (IterationElapsedTime < MinTime)
                    {
                        MinTime = IterationElapsedTime;
                    }
                    if (IterationElapsedTime > MaxTime)
                    {
                        MaxTime = IterationElapsedTime;
                    }
                }
                ElapsedTime   -= (MinTime + MaxTime);
                ElapsedSeconds = ElapsedTime * (1000.0 / (NIter * Stopwatch.Frequency));
                Console.WriteLine("{0,-12}\t{1}", u, ElapsedSeconds.ToString("F4"));
            }
            Console.WriteLine("\nCoctailSort [tablica generowana losowo]\nARRAY SIZE:\t TIME [ms]:");
            for (int u = 50000; u <= 200000; u += 10000)
            {
                int[] TestArray = new int[u];
                Array.Copy(ArrayRandom, TestArray, u);

                double ElapsedSeconds;
                long   ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;
                for (int n = 0; n < (NIter + 1 + 1); ++n)  // odejmujemy wartości skrajne
                {
                    long StartingTime = Stopwatch.GetTimestamp();
                    CocktailSort(TestArray);
                    long EndingTime = Stopwatch.GetTimestamp();
                    IterationElapsedTime = EndingTime - StartingTime;
                    ElapsedTime         += IterationElapsedTime;
                    if (IterationElapsedTime < MinTime)
                    {
                        MinTime = IterationElapsedTime;
                    }
                    if (IterationElapsedTime > MaxTime)
                    {
                        MaxTime = IterationElapsedTime;
                    }
                }
                ElapsedTime   -= (MinTime + MaxTime);
                ElapsedSeconds = ElapsedTime * (1000.0 / (NIter * Stopwatch.Frequency));
                Console.WriteLine("{0,-12}\t{1}", u, ElapsedSeconds.ToString("F4"));
            }
            Console.WriteLine("\nHeapSort [tablica generowana losowo]\nARRAY SIZE:\t TIME [ms]:");
            for (int u = 50000; u <= 200000; u += 10000)
            {
                int[] TestArray = new int[u];
                Array.Copy(ArrayRandom, TestArray, u);

                double ElapsedSeconds;
                long   ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;
                for (int n = 0; n < (NIter + 1 + 1); ++n)  // odejmujemy wartości skrajne
                {
                    long StartingTime = Stopwatch.GetTimestamp();
                    HeapSort(TestArray);
                    long EndingTime = Stopwatch.GetTimestamp();
                    IterationElapsedTime = EndingTime - StartingTime;
                    ElapsedTime         += IterationElapsedTime;
                    if (IterationElapsedTime < MinTime)
                    {
                        MinTime = IterationElapsedTime;
                    }
                    if (IterationElapsedTime > MaxTime)
                    {
                        MaxTime = IterationElapsedTime;
                    }
                }
                ElapsedTime   -= (MinTime + MaxTime);
                ElapsedSeconds = ElapsedTime * (1000.0 / (NIter * Stopwatch.Frequency));
                Console.WriteLine("{0,-12}\t{1}", u, ElapsedSeconds.ToString("F4"));
            }



            // Tablica rosnąca.
            int[] ArrayIncreasing = new int[200000];
            for (int j = 0; j < ArrayIncreasing.Length; j++)
            {
                ArrayIncreasing[j] = j;
            }

            Console.WriteLine("\nInsertionSort [tablica generowana rosnąco]\nARRAY SIZE:\t TIME [ms]:");
            for (int u = 50000; u <= 200000; u += 10000)
            {
                int[] TestArray = new int[u];
                Array.Copy(ArrayIncreasing, TestArray, u);

                double ElapsedSeconds;
                long   ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;
                for (int n = 0; n < (NIter + 1 + 1); ++n)  // odejmujemy wartości skrajne
                {
                    long StartingTime = Stopwatch.GetTimestamp();
                    InsertionSort(TestArray);
                    long EndingTime = Stopwatch.GetTimestamp();
                    IterationElapsedTime = EndingTime - StartingTime;
                    ElapsedTime         += IterationElapsedTime;
                    if (IterationElapsedTime < MinTime)
                    {
                        MinTime = IterationElapsedTime;
                    }
                    if (IterationElapsedTime > MaxTime)
                    {
                        MaxTime = IterationElapsedTime;
                    }
                }
                ElapsedTime   -= (MinTime + MaxTime);
                ElapsedSeconds = ElapsedTime * (1000.0 / (NIter * Stopwatch.Frequency));
                Console.WriteLine("{0,-12}\t{1}", u, ElapsedSeconds.ToString("F4"));
            }

            Console.WriteLine("\nSelectionSort [tablica generowana rosnąco]\nARRAY SIZE:\t TIME [ms]:");
            for (int u = 50000; u <= 200000; u += 10000)
            {
                int[] TestArray = new int[u];
                Array.Copy(ArrayIncreasing, TestArray, u);

                double ElapsedSeconds;
                long   ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;
                for (int n = 0; n < (NIter + 1 + 1); ++n)  // odejmujemy wartości skrajne
                {
                    long StartingTime = Stopwatch.GetTimestamp();
                    SelectionSort(TestArray);
                    long EndingTime = Stopwatch.GetTimestamp();
                    IterationElapsedTime = EndingTime - StartingTime;
                    ElapsedTime         += IterationElapsedTime;
                    if (IterationElapsedTime < MinTime)
                    {
                        MinTime = IterationElapsedTime;
                    }
                    if (IterationElapsedTime > MaxTime)
                    {
                        MaxTime = IterationElapsedTime;
                    }
                }
                ElapsedTime   -= (MinTime + MaxTime);
                ElapsedSeconds = ElapsedTime * (1000.0 / (NIter * Stopwatch.Frequency));
                Console.WriteLine("{0,-12}\t{1}", u, ElapsedSeconds.ToString("F4"));
            }
            Console.WriteLine("\nCoctailSort [tablica generowana rosnąco]\nARRAY SIZE:\t TIME [ms]:");
            for (int u = 50000; u <= 200000; u += 10000)
            {
                int[] TestArray = new int[u];
                Array.Copy(ArrayIncreasing, TestArray, u);

                double ElapsedSeconds;
                long   ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;
                for (int n = 0; n < (NIter + 1 + 1); ++n)  // odejmujemy wartości skrajne
                {
                    long StartingTime = Stopwatch.GetTimestamp();
                    CocktailSort(TestArray);
                    long EndingTime = Stopwatch.GetTimestamp();
                    IterationElapsedTime = EndingTime - StartingTime;
                    ElapsedTime         += IterationElapsedTime;
                    if (IterationElapsedTime < MinTime)
                    {
                        MinTime = IterationElapsedTime;
                    }
                    if (IterationElapsedTime > MaxTime)
                    {
                        MaxTime = IterationElapsedTime;
                    }
                }
                ElapsedTime   -= (MinTime + MaxTime);
                ElapsedSeconds = ElapsedTime * (1000.0 / (NIter * Stopwatch.Frequency));
                Console.WriteLine("{0,-12}\t{1}", u, ElapsedSeconds.ToString("F4"));
            }
            Console.WriteLine("\nHeapSort [tablica generowana rosnąco]\nARRAY SIZE:\t TIME [ms]:");
            for (int u = 50000; u <= 200000; u += 10000)
            {
                int[] TestArray = new int[u];
                Array.Copy(ArrayIncreasing, TestArray, u);

                double ElapsedSeconds;
                long   ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;
                for (int n = 0; n < (NIter + 1 + 1); ++n)  // odejmujemy wartości skrajne
                {
                    long StartingTime = Stopwatch.GetTimestamp();
                    HeapSort(TestArray);
                    long EndingTime = Stopwatch.GetTimestamp();
                    IterationElapsedTime = EndingTime - StartingTime;
                    ElapsedTime         += IterationElapsedTime;
                    if (IterationElapsedTime < MinTime)
                    {
                        MinTime = IterationElapsedTime;
                    }
                    if (IterationElapsedTime > MaxTime)
                    {
                        MaxTime = IterationElapsedTime;
                    }
                }
                ElapsedTime   -= (MinTime + MaxTime);
                ElapsedSeconds = ElapsedTime * (1000.0 / (NIter * Stopwatch.Frequency));
                Console.WriteLine("{0,-12}\t{1}", u, ElapsedSeconds.ToString("F4"));
            }


            // Tablica malejąca
            int[] ArrayDecreasing = new int[200000];
            for (int j = ArrayDecreasing.Length - 1; j >= 0; j--)
            {
                ArrayDecreasing[j] = j;
            }

            Console.WriteLine("\nInsertionSort [tablica generowana malejąco]\nARRAY SIZE:\t TIME [ms]:");
            for (int u = 50000; u <= 200000; u += 10000)
            {
                int[] TestArray = new int[u];
                Array.Copy(ArrayDecreasing, TestArray, u);

                double ElapsedSeconds;
                long   ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;
                for (int n = 0; n < (NIter + 1 + 1); ++n)  // odejmujemy wartości skrajne
                {
                    long StartingTime = Stopwatch.GetTimestamp();
                    InsertionSort(TestArray);
                    long EndingTime = Stopwatch.GetTimestamp();
                    IterationElapsedTime = EndingTime - StartingTime;
                    ElapsedTime         += IterationElapsedTime;
                    if (IterationElapsedTime < MinTime)
                    {
                        MinTime = IterationElapsedTime;
                    }
                    if (IterationElapsedTime > MaxTime)
                    {
                        MaxTime = IterationElapsedTime;
                    }
                }
                ElapsedTime   -= (MinTime + MaxTime);
                ElapsedSeconds = ElapsedTime * (1000.0 / (NIter * Stopwatch.Frequency));
                Console.WriteLine("{0,-12}\t{1}", u, ElapsedSeconds.ToString("F4"));
            }

            Console.WriteLine("\nSelectionSort [tablica generowana malejąco]\nARRAY SIZE:\t TIME [ms]:");
            for (int u = 50000; u <= 200000; u += 10000)
            {
                int[] TestArray = new int[u];
                Array.Copy(ArrayDecreasing, TestArray, u);

                double ElapsedSeconds;
                long   ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;
                for (int n = 0; n < (NIter + 1 + 1); ++n)  // odejmujemy wartości skrajne
                {
                    long StartingTime = Stopwatch.GetTimestamp();
                    SelectionSort(TestArray);
                    long EndingTime = Stopwatch.GetTimestamp();
                    IterationElapsedTime = EndingTime - StartingTime;
                    ElapsedTime         += IterationElapsedTime;
                    if (IterationElapsedTime < MinTime)
                    {
                        MinTime = IterationElapsedTime;
                    }
                    if (IterationElapsedTime > MaxTime)
                    {
                        MaxTime = IterationElapsedTime;
                    }
                }
                ElapsedTime   -= (MinTime + MaxTime);
                ElapsedSeconds = ElapsedTime * (1000.0 / (NIter * Stopwatch.Frequency));
                Console.WriteLine("{0,-12}\t{1}", u, ElapsedSeconds.ToString("F4"));
            }
            Console.WriteLine("\nCoctailSort [tablica generowana malejąco]\nARRAY SIZE:\t TIME [ms]:");
            for (int u = 50000; u <= 200000; u += 10000)
            {
                int[] TestArray = new int[u];
                Array.Copy(ArrayDecreasing, TestArray, u);

                double ElapsedSeconds;
                long   ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;
                for (int n = 0; n < (NIter + 1 + 1); ++n)  // odejmujemy wartości skrajne
                {
                    long StartingTime = Stopwatch.GetTimestamp();
                    CocktailSort(TestArray);
                    long EndingTime = Stopwatch.GetTimestamp();
                    IterationElapsedTime = EndingTime - StartingTime;
                    ElapsedTime         += IterationElapsedTime;
                    if (IterationElapsedTime < MinTime)
                    {
                        MinTime = IterationElapsedTime;
                    }
                    if (IterationElapsedTime > MaxTime)
                    {
                        MaxTime = IterationElapsedTime;
                    }
                }
                ElapsedTime   -= (MinTime + MaxTime);
                ElapsedSeconds = ElapsedTime * (1000.0 / (NIter * Stopwatch.Frequency));
                Console.WriteLine("{0,-12}\t{1}", u, ElapsedSeconds.ToString("F4"));
            }
            Console.WriteLine("\nHeapSort [tablica generowana malejąco]\nARRAY SIZE:\t TIME [ms]:");
            for (int u = 50000; u <= 200000; u += 10000)
            {
                int[] TestArray = new int[u];
                Array.Copy(ArrayDecreasing, TestArray, u);

                double ElapsedSeconds;
                long   ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;
                for (int n = 0; n < (NIter + 1 + 1); ++n)  // odejmujemy wartości skrajne
                {
                    long StartingTime = Stopwatch.GetTimestamp();
                    HeapSort(TestArray);
                    long EndingTime = Stopwatch.GetTimestamp();
                    IterationElapsedTime = EndingTime - StartingTime;
                    ElapsedTime         += IterationElapsedTime;
                    if (IterationElapsedTime < MinTime)
                    {
                        MinTime = IterationElapsedTime;
                    }
                    if (IterationElapsedTime > MaxTime)
                    {
                        MaxTime = IterationElapsedTime;
                    }
                }
                ElapsedTime   -= (MinTime + MaxTime);
                ElapsedSeconds = ElapsedTime * (1000.0 / (NIter * Stopwatch.Frequency));
                Console.WriteLine("{0,-12}\t{1}", u, ElapsedSeconds.ToString("F4"));
            }

            // Tablica stała
            int[]  ArrayConstant  = new int[200000];
            Random RandomNumber   = new Random(Guid.NewGuid().GetHashCode());
            int    ConstantNumber = RandomNumber.Next(int.MaxValue);

            for (int j = 0; j < ArrayConstant.Length; j++)
            {
                ArrayConstant[j] = ConstantNumber;
            }

            Console.WriteLine("\nInsertionSort [tablica stała]\nARRAY SIZE:\t TIME [ms]:");
            for (int u = 50000; u <= 200000; u += 10000)
            {
                int[] TestArray = new int[u];
                for (int j = 0; j < TestArray.Length; j++)
                {
                    TestArray[j] = 30;
                }

                double ElapsedSeconds;
                long   ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;
                for (int n = 0; n < (NIter + 1 + 1); ++n)  // odejmujemy wartości skrajne
                {
                    long StartingTime = Stopwatch.GetTimestamp();
                    InsertionSort(TestArray);
                    long EndingTime = Stopwatch.GetTimestamp();
                    IterationElapsedTime = EndingTime - StartingTime;
                    ElapsedTime         += IterationElapsedTime;
                    if (IterationElapsedTime < MinTime)
                    {
                        MinTime = IterationElapsedTime;
                    }
                    if (IterationElapsedTime > MaxTime)
                    {
                        MaxTime = IterationElapsedTime;
                    }
                }
                ElapsedTime   -= (MinTime + MaxTime);
                ElapsedSeconds = ElapsedTime * (1000.0 / (NIter * Stopwatch.Frequency));
                Console.WriteLine("{0,-12}\t{1}", u, ElapsedSeconds.ToString("F4"));
            }

            Console.WriteLine("\nSelectionSort [tablica stała (number = {0})]\nARRAY SIZE:\t TIME [ms]:", ConstantNumber);
            for (int u = 50000; u <= 200000; u += 10000)
            {
                int[] TestArray = new int[u];
                for (int j = 0; j < TestArray.Length; j++)
                {
                    TestArray[j] = 30;
                }

                double ElapsedSeconds;
                long   ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;
                for (int n = 0; n < (NIter + 1 + 1); ++n)  // odejmujemy wartości skrajne
                {
                    long StartingTime = Stopwatch.GetTimestamp();
                    SelectionSort(TestArray);
                    long EndingTime = Stopwatch.GetTimestamp();
                    IterationElapsedTime = EndingTime - StartingTime;
                    ElapsedTime         += IterationElapsedTime;
                    if (IterationElapsedTime < MinTime)
                    {
                        MinTime = IterationElapsedTime;
                    }
                    if (IterationElapsedTime > MaxTime)
                    {
                        MaxTime = IterationElapsedTime;
                    }
                }
                ElapsedTime   -= (MinTime + MaxTime);
                ElapsedSeconds = ElapsedTime * (1000.0 / (NIter * Stopwatch.Frequency));
                Console.WriteLine("{0,-12}\t{1}", u, ElapsedSeconds.ToString("F4"));
            }
            Console.WriteLine("\nCoctailSort [tablica stała]\nARRAY SIZE:\t TIME [ms]:");
            for (int u = 50000; u <= 200000; u += 10000)
            {
                int[] TestArray = new int[u];
                for (int j = 0; j < TestArray.Length; j++)
                {
                    TestArray[j] = 30;
                }

                double ElapsedSeconds;
                long   ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;
                for (int n = 0; n < (NIter + 1 + 1); ++n)  // odejmujemy wartości skrajne
                {
                    long StartingTime = Stopwatch.GetTimestamp();
                    CocktailSort(TestArray);
                    long EndingTime = Stopwatch.GetTimestamp();
                    IterationElapsedTime = EndingTime - StartingTime;
                    ElapsedTime         += IterationElapsedTime;
                    if (IterationElapsedTime < MinTime)
                    {
                        MinTime = IterationElapsedTime;
                    }
                    if (IterationElapsedTime > MaxTime)
                    {
                        MaxTime = IterationElapsedTime;
                    }
                }
                ElapsedTime   -= (MinTime + MaxTime);
                ElapsedSeconds = ElapsedTime * (1000.0 / (NIter * Stopwatch.Frequency));
                Console.WriteLine("{0,-12}\t{1}", u, ElapsedSeconds.ToString("F4"));
            }
            Console.WriteLine("\nHeapSort [tablica stała]\nARRAY SIZE:\t TIME [ms]:");
            for (int u = 50000; u <= 200000; u += 10000)
            {
                int[] TestArray = new int[u];
                for (int j = 0; j < TestArray.Length; j++)
                {
                    TestArray[j] = 30;
                }

                double ElapsedSeconds;
                long   ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;
                for (int n = 0; n < (NIter + 1 + 1); ++n)  // odejmujemy wartości skrajne
                {
                    long StartingTime = Stopwatch.GetTimestamp();
                    HeapSort(TestArray);
                    long EndingTime = Stopwatch.GetTimestamp();
                    IterationElapsedTime = EndingTime - StartingTime;
                    ElapsedTime         += IterationElapsedTime;
                    if (IterationElapsedTime < MinTime)
                    {
                        MinTime = IterationElapsedTime;
                    }
                    if (IterationElapsedTime > MaxTime)
                    {
                        MaxTime = IterationElapsedTime;
                    }
                }
                ElapsedTime   -= (MinTime + MaxTime);
                ElapsedSeconds = ElapsedTime * (1000.0 / (NIter * Stopwatch.Frequency));
                Console.WriteLine("{0,-12}\t{1}", u, ElapsedSeconds.ToString("F4"));
            }


            // Tablica V-kształtna
            int[] ArrayVShape = new int[200000];
            int   Index       = 0;

            for (int i = ArrayVShape.Length / 2; i > 0; i--)
            {
                ArrayVShape[Index++] = i;
            }
            for (int i = 0; i < ArrayVShape.Length / 2; i++)
            {
                ArrayVShape[Index++] = i;
            }


            Console.WriteLine("\nInsertionSort [tablica V-kształtna]\nARRAY SIZE:\t TIME [ms]:");
            for (int u = 50000; u <= 200000; u += 10000)
            {
                int[] TestArray = new int[u];
                Array.Copy(ArrayVShape, ((ArrayVShape.Length - u) / 2), TestArray, 0, u);

                double ElapsedSeconds;
                long   ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;
                for (int n = 0; n < (NIter + 1 + 1); ++n)  // odejmujemy wartości skrajne
                {
                    long StartingTime = Stopwatch.GetTimestamp();
                    InsertionSort(TestArray);
                    long EndingTime = Stopwatch.GetTimestamp();
                    IterationElapsedTime = EndingTime - StartingTime;
                    ElapsedTime         += IterationElapsedTime;
                    if (IterationElapsedTime < MinTime)
                    {
                        MinTime = IterationElapsedTime;
                    }
                    if (IterationElapsedTime > MaxTime)
                    {
                        MaxTime = IterationElapsedTime;
                    }
                }
                ElapsedTime   -= (MinTime + MaxTime);
                ElapsedSeconds = ElapsedTime * (1000.0 / (NIter * Stopwatch.Frequency));
                Console.WriteLine("{0,-12}\t{1}", u, ElapsedSeconds.ToString("F4"));
            }

            Console.WriteLine("\nSelectionSort [tablica V-kształtna]\nARRAY SIZE:\t TIME [ms]:");
            for (int u = 50000; u <= 200000; u += 10000)
            {
                int[] TestArray = new int[u];
                Array.Copy(ArrayVShape, ((ArrayVShape.Length - u) / 2), TestArray, 0, u);

                double ElapsedSeconds;
                long   ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;
                for (int n = 0; n < (NIter + 1 + 1); ++n)  // odejmujemy wartości skrajne
                {
                    long StartingTime = Stopwatch.GetTimestamp();
                    SelectionSort(TestArray);
                    long EndingTime = Stopwatch.GetTimestamp();
                    IterationElapsedTime = EndingTime - StartingTime;
                    ElapsedTime         += IterationElapsedTime;
                    if (IterationElapsedTime < MinTime)
                    {
                        MinTime = IterationElapsedTime;
                    }
                    if (IterationElapsedTime > MaxTime)
                    {
                        MaxTime = IterationElapsedTime;
                    }
                }
                ElapsedTime   -= (MinTime + MaxTime);
                ElapsedSeconds = ElapsedTime * (1000.0 / (NIter * Stopwatch.Frequency));
                Console.WriteLine("{0,-12}\t{1}", u, ElapsedSeconds.ToString("F4"));
            }
            Console.WriteLine("\nCoctailSort [tablica V-kształtna]\nARRAY SIZE:\t TIME [ms]:");
            for (int u = 50000; u <= 200000; u += 10000)
            {
                int[] TestArray = new int[u];
                Array.Copy(ArrayVShape, ((ArrayVShape.Length - u) / 2), TestArray, 0, u);

                double ElapsedSeconds;
                long   ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;
                for (int n = 0; n < (NIter + 1 + 1); ++n)  // odejmujemy wartości skrajne
                {
                    long StartingTime = Stopwatch.GetTimestamp();
                    CocktailSort(TestArray);
                    long EndingTime = Stopwatch.GetTimestamp();
                    IterationElapsedTime = EndingTime - StartingTime;
                    ElapsedTime         += IterationElapsedTime;
                    if (IterationElapsedTime < MinTime)
                    {
                        MinTime = IterationElapsedTime;
                    }
                    if (IterationElapsedTime > MaxTime)
                    {
                        MaxTime = IterationElapsedTime;
                    }
                }
                ElapsedTime   -= (MinTime + MaxTime);
                ElapsedSeconds = ElapsedTime * (1000.0 / (NIter * Stopwatch.Frequency));
                Console.WriteLine("{0,-12}\t{1}", u, ElapsedSeconds.ToString("F4"));
            }
            Console.WriteLine("\nHeapSort [tablica V-kształtna]\nARRAY SIZE:\t TIME [ms]:");
            for (int u = 50000; u <= 200000; u += 10000)
            {
                int[] TestArray = new int[u];
                Array.Copy(ArrayVShape, ((ArrayVShape.Length - u) / 2), TestArray, 0, u);

                double ElapsedSeconds;
                long   ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;
                for (int n = 0; n < (NIter + 1 + 1); ++n)  // odejmujemy wartości skrajne
                {
                    long StartingTime = Stopwatch.GetTimestamp();
                    HeapSort(TestArray);
                    long EndingTime = Stopwatch.GetTimestamp();
                    IterationElapsedTime = EndingTime - StartingTime;
                    ElapsedTime         += IterationElapsedTime;
                    if (IterationElapsedTime < MinTime)
                    {
                        MinTime = IterationElapsedTime;
                    }
                    if (IterationElapsedTime > MaxTime)
                    {
                        MaxTime = IterationElapsedTime;
                    }
                }
                ElapsedTime   -= (MinTime + MaxTime);
                ElapsedSeconds = ElapsedTime * (1000.0 / (NIter * Stopwatch.Frequency));
                Console.WriteLine("{0,-12}\t{1}", u, ElapsedSeconds.ToString("F4"));
            }

            Console.WriteLine("Uwaga! Nastąpi wyjście z programu, Skopiuj i zapisz wyniki!");
            Console.ReadLine();
            Console.ReadLine();
        }
Beispiel #15
0
        static void Main(string[] args)
        {
            int iterationCounter  = 10;
            int iterationCounter2 = 28;

            int[] tablica = new int[(int)Math.Pow(2, 28)];

            for (int i = 0; i < tablica.Length; i++)
            {
                tablica[i] = i;
            }


            //1
            Console.WriteLine("\nWyszukiwanie liniowe [ocena przy użyciu instrumentacji]\n");
            lookingForNumber = (tablica.Length - 1) / iterationCounter;
            ulong averagaCounter = 0;

            Console.WriteLine("TRY\tSTEPS\t\tNUMBER\t\tFOUND?");
            for (int i = 0; i < iterationCounter; i++)
            {
                counter = 0;
                test    = IsPresent_InstrumentalLineSearch(tablica, lookingForNumber);
                Console.WriteLine("{0}\t{1,-10}\t{2,-10}\t{3}", i + 1, counter, lookingForNumber, test);
                if (i == iterationCounter - 2)
                {
                    lookingForNumber = tablica.Length - 1;
                }
                else
                {
                    lookingForNumber += (tablica.Length - 1) / iterationCounter;
                }
                averagaCounter += counter;
            }

            Console.WriteLine("\nŚrednia złożoność wynosi: {0} kroków.", (double)averagaCounter / iterationCounter);
            Console.WriteLine("---------------------------------------------\n");


            //2
            Console.WriteLine("\nWyszukiwanie liniowe [ocena przy wykorzystaniu pomiaru czasu wykonania]\n");
            lookingForNumber = (tablica.Length - 1) / iterationCounter;
            double averagaCounter2 = 0;

            Console.WriteLine("TRY\tTIME[ms]\tNUMBER\t\tFOUND?");

            for (int i = 0; i < iterationCounter; i++)
            {
                double ElapsedSeconds;
                long   ElapsedTime = 0, MinTime = long.MaxValue, MaxTime = long.MinValue, IterationElapsedTime;
                for (int n = 0; n < (iterationCounter + 1 + 1); ++n) // odejmujemy wartości skrajne
                {
                    long StartingTime = Stopwatch.GetTimestamp();
                    test = IsPresent_TimeStampLineSearch(tablica, lookingForNumber);
                    long EndingTime = Stopwatch.GetTimestamp();
                    IterationElapsedTime = EndingTime - StartingTime;
                    ElapsedTime         += IterationElapsedTime;
                    Console.Write("{0}: [{1:P0}]\r", i + 1, (float)n / (iterationCounter + 1));  //wskaźnik postępu
                    if (IterationElapsedTime < MinTime)
                    {
                        MinTime = IterationElapsedTime;
                    }
                    if (IterationElapsedTime > MaxTime)
                    {
                        MaxTime = IterationElapsedTime;
                    }
                }
                ElapsedTime   -= (MinTime + MaxTime);
                ElapsedSeconds = ElapsedTime * (1000.0 / (iterationCounter * Stopwatch.Frequency));
                Console.WriteLine("{0}\t{1,-10}\t{2}\t{3}", i + 1, ElapsedSeconds.ToString("F4"), lookingForNumber, test);
                if (i == iterationCounter - 2)
                {
                    lookingForNumber = tablica.Length - 1;
                }
                else
                {
                    lookingForNumber += (tablica.Length - 1) / iterationCounter;
                }
                averagaCounter2 += ElapsedSeconds;
            }

            Console.WriteLine("\nŚrednia złożoność wynosi: {0}[ms]", averagaCounter2 / iterationCounter);
            Console.WriteLine("---------------------------------------------\n");



            //3
            Console.WriteLine("\nWyszukiwanie binarne [ocena przy użyciu instrumentacji]\n");
            lookingForNumber = (tablica.Length - 1) / 2;
            ulong averagaCounter3 = 0;

            Console.WriteLine("TRY\tSTEPS\t\tNUMBER\t\tFOUND?");

            for (int i = 0; i < iterationCounter2; i++)
            {
                counter = 0;
                test    = IsPresent_InstrumentalBinaryTreeSearch2(tablica, lookingForNumber);
                Console.WriteLine("{0}\t{1}\t\t{2,-10}\t{3}", i + 1, counter, lookingForNumber, test);
                lookingForNumber = lookingForNumber / 2;
                averagaCounter3 += counter;
            }

            Console.WriteLine("\nŚrednia złożoność wynosi: {0} kroków.", (double)averagaCounter3 / iterationCounter2);
            Console.WriteLine("---------------------------------------------\n");



            //4
            Console.WriteLine("\nWyszukiwanie binarne [ocena przy wykorzystaniu pomiaru czasu wykonania]\n");
            lookingForNumber = (tablica.Length - 1) / 2;
            double averagaCounter4 = 0;

            Console.WriteLine("TRY\tTIME[µs]\tNUMBER\t\tFOUND?");

            for (int i = 0; i < iterationCounter2; i++)
            {
                double ElapsedSeconds2;
                long   ElapsedTime2 = 0, MinTime2 = long.MaxValue, MaxTime2 = long.MinValue, IterationElapsedTime2;
                for (int n = 0; n < (iterationCounter2 * precisionFactor + 1 + 1); ++n) // odejmujemy wartości skrajne
                {
                    long StartingTime2 = Stopwatch.GetTimestamp();
                    test = IsPresent_TimeStampBinaryTreeSearch2(tablica, lookingForNumber);
                    long EndingTime2 = Stopwatch.GetTimestamp();
                    IterationElapsedTime2 = EndingTime2 - StartingTime2;
                    ElapsedTime2         += IterationElapsedTime2;
                    Console.Write("{0}: [{1:P0}]\r", i + 1, (float)n / (iterationCounter2 * precisionFactor + 1));  //wskaźnik postępu
                    if (IterationElapsedTime2 < MinTime2)
                    {
                        MinTime2 = IterationElapsedTime2;
                    }
                    if (IterationElapsedTime2 > MaxTime2)
                    {
                        MaxTime2 = IterationElapsedTime2;
                    }
                }
                ElapsedTime2   -= (MinTime2 + MaxTime2);
                ElapsedSeconds2 = ElapsedTime2 * (1000000.0 / (precisionFactor * iterationCounter2 * Stopwatch.Frequency));
                Console.WriteLine("{0}:\t{1}\t{2,-10}\t{3}", i + 1, ElapsedSeconds2.ToString("F8"), lookingForNumber, test);
                lookingForNumber = lookingForNumber / 2;
                averagaCounter4 += ElapsedSeconds2;
            }

            Console.WriteLine("\nŚrednia złożoność wynosi: {0}[µs]", (double)averagaCounter4 / iterationCounter2);
            Console.WriteLine("---------------------------------------------\n");


            Console.ReadLine();
        }