Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <fstream>
- #include <random>
- #include <ctime>
- #include <windows.h>
- #include "biblioteka.h"
- using namespace std;
- double PCFreq = 0.0;
- __int64 CounterStart = 0;
- void StartCounter()
- {
- LARGE_INTEGER li;
- if(!QueryPerformanceFrequency(&li))
- cout << "QueryPerformanceFrequency failed!\n";
- PCFreq = double(li.QuadPart)/1000.0;
- QueryPerformanceCounter(&li);
- CounterStart = li.QuadPart;
- }
- double GetCounter()
- {
- LARGE_INTEGER li;
- QueryPerformanceCounter(&li);
- return double(li.QuadPart-CounterStart)/PCFreq;
- }
- int main()
- {
- // string text;
- // ifstream plik;
- // plik.open("tekst.txt", ios::in);
- // if(plik.is_open())
- // {
- // getline(plik, text);
- // plik.close();
- // }
- // string pattern;
- // cout << "Podaj wzorzec\n> ";
- // getline(cin, pattern);
- // cout << "Podany wzorzec to: " << pattern << endl;
- //
- // Search test(text, pattern);
- //
- // StartCounter();
- // test.MorrisKnuth();
- // cout << GetCounter() << endl;
- //
- // StartCounter();
- // test.Sunday();
- // cout << GetCounter() << endl;
- //
- // return 0;
- random_device rd;
- mt19937 gen(time(NULL));
- normal_distribution<> dis(77.0, 2.0);
- string sunday = "wynikSun.txt";
- ofstream sundayW(sunday.c_str());
- string knuth = "wynikKnuth.txt";
- ofstream knuthW(knuth.c_str());
- string pattern;
- double tmp;
- char c1;
- for(int i = 0; i < 5; i++)
- {
- tmp = dis(gen);
- if(tmp < 0.0)
- tmp = 0.0;
- if(tmp > 255.0)
- tmp = 255.0;
- c1 = lround(tmp);
- pattern += c1;
- }
- for(int h = 0; h < 100; h++) // petla do zliczania sredniej z testow wariancji
- {
- string text;
- double tmp2;
- char c2;
- for(int i = 0; i < 100000; i++)
- {
- tmp2 = dis(gen);
- if(tmp2 < 0.0)
- tmp2 = 0.0;
- if(tmp2 > 255.0)
- tmp2 = 255.0;
- c2 = lround(tmp2);
- text += c2;
- }
- //cout << "Tekst: " << text << endl;
- //cout << "Wzor: " << pattern << endl;
- Search test2(text, pattern);
- StartCounter();
- test2.MorrisKnuth();
- //cout << GetCounter() << endl;
- knuthW << GetCounter() << endl;
- StartCounter();
- test2.Sunday();
- //cout << GetCounter() << endl;
- sundayW << GetCounter() << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement