#include #include #include #include #include "strin.h" #include "copywrite.h" #include #include using namespace std; long long TimeValue=0; long long time_RDTSC() { // asm("rdtsc"); _asm rdtsc } void time_start() { TimeValue=time_RDTSC(); } long long time_stop() { return time_RDTSC()-TimeValue; } int main() { int i,j; char namefile[50]; char buf[1000]; int N,len; // ofstream outfile; ifstream infile; cout << "filename: "; cin >> namefile; cout << "lines: "; cin >> N; cout << "line length: "; cin >> len; ofstream outfile(namefile, ios::out); if (!outfile) { cout << "Oshibka pri chtenii faila\n"; return 0; } else { char * str = new char[len*100000]; for(i=0; i cont1; vector cont2; infile.open(namefile); if (!infile) cout << "Error opening file\n"; else { while(!infile.eof()) { infile.getline(buf, len+1); if(N<20) cout << buf << "\n"; Strings s1(buf); copywrite s2(buf); cont1.push_back(s1); cont2.push_back(s2); } infile.close(); } time_start(); sort(cont1.begin(), cont1.end()); cout << "Vremya sortirovki klassicheskoi stroki! " << time_stop() << "\n"; if(N<20) { for(vector::iterator i = cont1.begin(); i < cont1.end(); i++) i -> print(); } time_start(); sort(cont2.begin(), cont2.end()); cout << "Vremya sortirovki copy on write stroki! " << time_stop()/100 << "\n"; if (N<20) { for(vector::iterator i = cont2.begin(); i < cont2.end(); i++) i -> print(); } getchar(); getchar(); return (0); }