-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
83 lines (64 loc) · 2.3 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
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "cachecontrol.h"
#include <time.h>
void poolcache() {
// cria a quantidade de níveis de cache solcitados
//enquanto não tiver retorno do dado
// busca no próximo nível de cache
}
int main() {
clock_t inicio, fim;
double tempo;
unsigned long int contador = 0;
cachecontrol m = cachecontrol("cachecontrol.conf.xml");
//cachecontrol m = cachecontrol();
//m.processaComando("I,8,1");
//m.processaComando("I,0,1");
//m.processaComando("I,8,1");
//m.processaComando("I,10,1");
//string arquivo = "trace_nano_grande.txt";
//string arquivo = "trace_ls_medio.txt";
string arquivo = "trace_hello_pequeno.txt";
string linha;
ifstream fs (arquivo);
if (fs.is_open())
{
inicio = clock();
while (! fs.eof() ) {
getline (fs, linha);
if (!linha.empty()) {
//cout << linha << endl;
m.processaComando(linha);
contador++;
}
}
fim = clock();
tempo = ((double)(fim - inicio)) / CLOCKS_PER_SEC;
//fs.close();
}
cout << "Total de comandos processados: " << contador << endl;
cout.precision(5);
cout << endl;
cout << "Tempo de execução: " << fixed << tempo << " segundos " << endl;
cout << endl;
// quantidade de níveis de cahce configurados
int L = 2;
int mi, h, l, g;
for (int i = 0; i < L; i++) {
mi = m.getMissesDados(i);
h = m.getHitsDados(i);
l = m.getLeiturasDados(i);
g = m.getGravacoesDados(i);
cout << "Cache de Dados L" << (i+1) << ": " << endl;
cout << "misses = " << mi << " Hits = " << h << " total = " << mi+h << endl;
cout << "leituras = " << l << " Gravacoes = " << g << " total = " << l +g << endl;
mi = m.getMissesInstrucoes(i);
h = m.getHitsInstrucoes(i);
l = m.getLeiturasInstrucoes(i);
g = m.getGravacoesInstrucoes(i);
cout << endl;
cout << "Cache de Instruções L" << (i+1) << ": " << endl;
cout << "misses = " << mi << " Hits = " << h << " total = " << mi+h << endl;
cout << "leituras = " << l << " Gravacoes = " << g << " total = " << l +g << endl;
cout << endl;
}
}