Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cstdlib>
- #include <string>
- #include <vector>
- #include <map>
- #include <unordered_map>
- #include <set>
- #include <list>
- #include <sys/stat.h>
- using namespace std;
- int main(int argc, char *argv[], char *env[])
- {
- string file_name;
- if(argc==2)
- file_name = string(argv[1]);
- else
- file_name = "s:\\big_text_file.dat";
- ifstream f(file_name);
- if (!f)
- {
- cerr<<"Nem sikerült megnyitni a \""<<file_name<<"\" fájlt...!\n";
- return 1;
- }
- string row;
- vector<string> rows;
- int i=0,rows_length=0;
- while(getline(f,row))
- {
- i++;
- rows_length+=row.length()+2;
- rows.push_back(row);
- /*
- cerr.setf(ios::right);
- cerr<<"i="<<i<<"\t"
- <<"string -> addr / size / összes. : "<<&row <<" / "<<row.size()<<" / "<<rows_length<<"\t"
- <<"vector -> addr / size / capacity : "<<&rows<<" / "<<rows.size()<<" / "<<rows.capacity()<<" ["<<rows.size()*100/rows.capacity()<<"%]\t\r";
- */
- }
- cout << endl
- << "sorok... "<<endl
- << " száma: "<<i<<endl
- << " hossza összesen: "<<rows_length<<" darab karakter"<<endl<<endl;
- cout << "vektor... "<<endl
- << " méret: "<<rows.size()<<" darab"<<endl
- << " kapacitás: "<<rows.capacity()<<" darab"<<endl
- //<< " max.méret: "<<rows.max_size()<<endl
- <<endl;
- cout <<"shrink..."<<endl;
- rows.shrink_to_fit();
- cout << "vektor... "<<endl
- << " méret: "<<rows.size()<<" darab"<<endl
- << " kapacitás: "<<rows.capacity()<<" darab"<<endl
- //<< " max.méret: "<<rows.max_size()<<endl
- <<endl;
- struct stat s;
- stat(file_name.c_str(),&s);
- cout << "fájl méret: "<<s.st_size<<" byte ("<<s.st_size/1024<<" Kbyte)"<<endl<<endl;
- cout << endl; system("\"tasklist /fi \"imagename eq file_to_vector.exe\"");
- cout << endl; system("\"powershell -c \"get-process file_to_vector\"");
- // cout << endl; system('ps -C file_to_vector -O rss | awk \'{count++;sum+=$2}; END {count--;print"Count =",count;print"Sum =",sum/1024,"MB";};\'');
- cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement