int main() { string test; Stoper czasomierz; int zakresy[] = {10, 100, 10000, 1000000, 1000000000}; fstream plik; plik.open( "nazwiska.txt", std::ios::in | std::ios::out ); for(int j=0; j<(int)(sizeof(zakresy)/sizeof(zakresy[0])); j++) { Tablica_asc ksiazka; czasomierz.start(); for(int i=0; i<zakresy[j]; i++) { getline(plik, test); ksiazka.dodaj(123456, test); } czasomierz.stop(); //ksiazka.wypisz(); cout<<czasomierz.getTime()<<" sekund. Dzieki, dzieki, siema!"<<endl; getchar(); ksiazka.reset(); } /* czasomierz.start(); cout<<ksiazka.szukaj("partyka22")<<endl; czasomierz.stop(); cout<<czasomierz.getTime()<<" sekund"<<endl; */ }
int main() { srand(time(NULL)); List lista; Queue zakresy; Stoper czasomierz; int aktualny_zakres, ilosc_elementow; zakresy.push(10); zakresy.push(100); zakresy.push(1000); zakresy.push(1000000); zakresy.push(1000000000); ilosc_elementow = zakresy.size(); for (int i=0; i<ilosc_elementow; i++) { aktualny_zakres = zakresy.pop().element; cout<<"aktualny zakres: "<<aktualny_zakres<<endl; for (int j=0; j<aktualny_zakres; j++) { lista.add(j, j+1); } czasomierz.start(); lista.wyszukaj(rand()%aktualny_zakres); czasomierz.stop(); cout<<"Wyszukanie losowego elementu zajelo: "<<czasomierz.getTime()<<" sekund"<<endl; lista.wyczysc(); } }
void Stoper::start(std::string name, bool from_beginning) { Stoper * stoper = findStoper(name, false); if (stoper) //stoper exists { stoper->start(from_beginning); } else //stoper not exists { Stoper *stoper = new Stoper(); stopers.insert(std::make_pair(name, stoper)); stoper->start(true); } }
int main(int Argc, char* Argv[]) { srand(time(NULL)); graph* graph1 = NULL; Stoper stoper; int number_of_vertices[4]={10,100,1000,10000}; for(int i=0; i<4; i++) { graph1 = new graph(number_of_vertices[i]); for(int j=1; j<=(number_of_vertices[i]/2); j++) { if(j==1) graph1->add_edge(j, j*2, rand()); else { graph1->add_edge(j, j*2, rand()); graph1->add_edge(j, (j*2)-1, rand()); } } for(int j=number_of_vertices[i]; j>3; j--) graph1->add_edge(j, j-1, rand()); stoper.Start(); graph1->BBsearch(number_of_vertices[i]/2); stoper.Stop(); std::cout<<"Czas wyszukania Branch and Bound dla grafu "<<number_of_vertices[i]<<" elementowego wynosi: "<<stoper.getElapsedTime()<<"ms."<<std::endl<<std::endl; stoper.Start(); graph1->BBsearch_with_extended_list(number_of_vertices[i]/2); stoper.Stop(); std::cout<<"Czas wyszukania B&B with extended list dla grafu "<<number_of_vertices[i]<<" elementowego wynosi: "<<stoper.getElapsedTime()<<"ms."<<std::endl<<std::endl; delete graph1; } return 0; }