forked from GarCoSim/TraceFileSim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
71 lines (54 loc) · 1.47 KB
/
main.cpp
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
64
65
66
67
68
69
/*
* main.cpp
*
* Created on: Sep 3, 2013
* Author: kons
*/
#include "Objects/Simulator.h"
#include <stdio.h>
#include <stdlib.h>
#include <ctime>
using namespace traceFileSimulator;
using namespace std;
//logging vars
int gLineInTrace;
int gAllocations;
FILE* gLogFile;
FILE* gDetLog;
int main(int argc, char *argv[]) {
if(argc != 4){
fprintf(stderr,"Not enough arguments provided. \n"
"Usage: GCKons traceFile heapsize highWatermark\n");
exit(1);
}
if(WRITE_DETAILED_LOG == 1){
gDetLog = fopen("detailed.log","w+");
}
//set up global logfile
gLogFile = fopen("gcLog.log", "w+");
fprintf(gLogFile, "%8s | %9s | %9s | %14s "
"| %13s | %10s | %10s |\n",
"LINE", "GC REASON", "Total GCs:", "Objects freed:", "live objects:",
"heap used:", "free heap:");
char* filename = argv[1];
int heapSize = atoi(argv[2]);
int highWatermark = atoi(argv[3]);
//start measuring time
clock_t start = clock();
Simulator* simulator = new Simulator(filename, heapSize, highWatermark);
while(simulator->lastStepWorked() == 1){
simulator->doNextStep();
if(WRITE_DETAILED_LOG == 1){
fflush(gDetLog);
}
}
//
simulator->printStats();
clock_t end = clock();
double elapsed_secs = double(end - start)/CLOCKS_PER_SEC;
//double elapsed_msecs = (double)(double)(end - start)/(CLOCKS_PER_SEC/1000);
printf("End. Execution took: %f seconds\n", elapsed_secs);
fprintf(gLogFile,"Execution finished after %f seconds\n", elapsed_secs);
fclose(gLogFile);
return 0;
}