-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
29 lines (23 loc) · 773 Bytes
/
Copy pathmain.cpp
File metadata and controls
29 lines (23 loc) · 773 Bytes
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
#include "BMgr.h"
using namespace std;
int main()
{
// 创建数据库文件
BMgr* bmgr = new BMgr("data/data.dbf");
for (int i = 0; i < MAXPAGES; i++)
bmgr->FixNewPage();
FILE* request_file = fopen("data/data-5w-50w-zipf.txt", "r");
int page_id, op;
clock_t start = clock();
for (int i = 0; i < REQUESTNUM; i++)
{
fscanf(request_file, "%d,%d", &op, &page_id);
bmgr->FixPage(page_id, op);
bmgr->UnfixPage(page_id);
}
printf("hit number: %lld\n", bmgr->GetNumHit());
printf("hit rate: %.2lf%%\n", bmgr->GetNumHit() * 100.0 / REQUESTNUM );
printf("io number: %lld\n", bmgr->GetNumDiskIO());
printf("time taken: %.2fs\n", (double)(clock() - start) / CLOCKS_PER_SEC);
return 0;
}