-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpp_file.cpp
More file actions
63 lines (52 loc) · 1.26 KB
/
cpp_file.cpp
File metadata and controls
63 lines (52 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <iostream>
#include <fstream>
#include <time.h>
#include <string>
#include <sstream>
#include <typeinfo>
#include <iomanip>
using namespace std;
int main(){
clock_t start, end;
double cpu_time_used;
string list[] = {"10MB.txt","20MB.txt","30MB.txt","40MB.txt","50MB.txt"};
// double time[5];
string line;
ifstream infile;
ofstream outfile;
ofstream outfile1;
outfile1.open("c++_temp.csv",ofstream::out);
for(int i=0;i<5;i++){
start = clock();
infile.open(list[i]);
outfile.open("cpp_copy.txt",ofstream::out);
/* if (infile.is_open()){
cout<<"dfg"<<list[i]<<endl;
infile.close();
}
else cout << "Unable to open file";
char ch;
while(!infile.eof()){
infile.get(ch);
outfile<<ch;
} */
while(getline(infile,line)){
outfile<<line;
}
infile.close();
outfile.close();
end = clock();
cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;
// cout<<fixed<<setprecision(2)<<cpu_time_used<<endl;
// time[i] = cpu_time_used;
outfile1<<fixed<<setprecision(2)<<cpu_time_used;
outfile1<<",";
/* ostringstream strs;
strs << time[i];
string str = strs.str();
outfile1<<str;
*/
}
outfile1<<"\n";
outfile1.close();
}