// Sistemas Operacionais
// Cássio Pinheiro
// Observando a Estrutura de Memória
// Usar arq1 e arq2 monitorando CPU e memória
#include <iostream>
#include <time.h>
#include <fstream>
using namespace std;
int main() {
for( int i = 0; i < 10; i++ ) {
clock_t tTmpIni = clock();
string line;
ifstream myfile( "arq1.txt" );
if( myfile.is_open() ) {
while( ! myfile.eof() ) getline( myfile, line );
myfile.close();
}
else cout << "erro: abertura de arquivo" << endl;
cout << "Acesso " << ( i + 1 ) << " em " << ( ( clock() - tTmpIni ) / ( CLOCKS_PER_SEC / 1000 ) ) << " milisegundos" << endl;
}
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: