forked from jiangxincode/CacheSim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileTest.cpp
More file actions
46 lines (40 loc) · 1.11 KB
/
FileTest.cpp
File metadata and controls
46 lines (40 loc) · 1.11 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
#include "base.h"
using namespace std;
void FileTest(void)
{
char filepath[100];
ifstream in_file;
char address[13];
cout << "\nPlease input the path and name that you want to test!" << endl;
cout << "\n\t C:\\temp\\myfile.trace" << endl;
cout << "\n\t myfile.trace" << endl;
cin >> filepath;
in_file.open(filepath,ios::in);
while(in_file.fail())
{
cout << "Open ERROR! Please Check the Path and Name, and Input again!" << endl;
cin >> filepath;
in_file.open(filepath,ios::in);
}
#ifdef OUTPUT
int i_line_proceded = 0;
ofstream out_put;
out_put.open("test.log",ios::out);
#endif // OUTPUT
while(!in_file.eof())
{
in_file.getline(address,13);
bool __attribute__((unused)) is_success = GetHitNum(address); //in case of the warning of "Wunused-but-set-variable"
assert(is_success);
#ifdef OUTPUT
i_line_proceded++;
out_put << i_line_proceded << endl;
cout << address << endl;
#endif // OUTPUT
}
#ifdef OUTPUT
out_put.close();
#endif // OUTPUT
in_file.close();
GetHitRate();
}