Árvore de páginas

Versões comparadas

Chave

  • Esta linha foi adicionada.
  • Esta linha foi removida.
  • A formatação mudou.

...

Expandir
titleVerifique o código utilizado
Bloco de código
languagecpp
firstline1
titlemallocio.cpp
linenumberstrue
#include "pch.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>

using namespace std;
int main()
{
    	void *var = 0;

    	time_t timer;
    	time_t timer2;
    	struct tm y2k = { 0 };
	double seconds;
	string msgret;

	printf("  __  __    _    _     _   double seconds;
    string msgret;

    printf("TESTE 1\n");
    printf("  ___   ____     ___ ___  \n");
	printf(" |  \\/  |  / \\  | |   | |   / _ \\ / ___|   |_ _/ _ \\ \n");
	printf(" | |\\/| | / _ \\ | |   | |  | | | | |   _____| | | | |\n");
	printf(" | |  | |/ ___ \\| |___| |__| |_| | |__|_____| | |_| |\n");
	printf(" |_|  |_/_/   \\_\\_____|_____\\___/ \\____|   |___\\___/ \n");
	printf("                                               xVs xArc\n");
	printf("                                                   \n");
	printf(" \n");
	
	printf("TESTE 1\n");
	printf("ALOCANDO BLOCO DE MEMORIA\n");

    	y2k.tm_hour = 0;   y2k.tm_min = 0; y2k.tm_sec = 0;
    	y2k.tm_year = 100; y2k.tm_mon = 0; y2k.tm_mday = 1;
    	timer = time(NULL);

    	for (int i = 0; i < 300000000; i++)
    	{
        		var = malloc(100);
        		free(var);
    	}

    	timer2 = time(NULL);
    	seconds = timer2 - timer;

    	printf("TEMPO LEVADO PARA ALOCAR MEMORIA: %f segundos\n", seconds);
	printf(" \n");
	if (seconds <= 10) {
		printf("RESULTADO DO TESTE: Otimo -> RECOMENDADO PARA O PROTHEUS\n");
	}
	else if (seconds > 10 && seconds <= 15) {
		printf("RESULTADO DO TESTE 2: Bom -> NAO recomendado para o Protheus\n");
	}
	else if (seconds > 15 && seconds <= 25) {
		printf("LEITURA EM DISCORESULTADO DO TESTE: Ruim -> NAO recomendado para o Protheus\n");
	}
	else {
		printf("RESULTADO DO TESTE: Pessimo -> NAO recomendado para o Protheus\n");
	}

	printf(" \n");
	printf(" \n");
	printf("TESTE 2\n");
	printf("LEITURA EM DISCO\n");

	y2k.tm_hour = 0;   y2k.tm_min = 0; y2k.tm_sec = 0;
    	y2k.tm_year = 100; y2k.tm_mon = 0; y2k.tm_mday = 1;
    	timer = time(NULL);

    	char * buffer;
    	FILE *pFile = fopen("teste.txt", "rb");
    	long lSize = ftell(pFile);
    	size_t result;
    	buffer = (char*)malloc(sizeof(char)*lSize);
    	for (int i = 0; i < 7000000; i++)
    	{
        		fseek(pFile, 0, SEEK_END);
        		result = fread(buffer, 1, lSize, pFile);
	}
	fclose(pFile);
	free(buffer);
	timer2 = time(NULL);
	seconds  }
    fclose(pFile);
    free(buffer);
    timer2 = time(NULL);
    seconds = timer2 - timer;

    printf("TEMPO LEVADO PARA REALIZAR A LEITURA EM DISCO: %f segundos\n", seconds= timer2 - timer;

	printf("TEMPO LEVADO PARA REALIZAR A LEITURA EM DISCO: %f segundos\n", seconds);
	printf(" \n");
	if (seconds <= 10) {
		printf("RESULTADO DO TESTE: Otimo -> RECOMENDADO PARA O PROTHEUS\n");
	}
	else if (seconds > 10 && seconds <= 25) {
		printf("RESULTADO DO TESTE: Bom -> NAO recomendado para o Protheus\n");
	}
	else if (seconds > 25 && seconds <= 26) {
		printf("RESULTADO DO TESTE: Ruim -> NAO recomendado para o Protheus\n");
	}
	else {
		printf("RESULTADO DO TESTE: Pessimo -> NAO recomendado para o Protheus\n");
	}

	printf(" \n");
	printf(" \n");
	printf(" ***********************************************************************\n");
	printf(" \n");
	printf(" TABELA DE REFERENCIA - ALOCAR BLOCO DE MEMORIA\n");
	printf(" \n");
	printf("Otimo   - ate 10.000000 segundos (RECOMENDADO PARA O PROTHEUS)\n");
	printf("Bom     - ate 15.000000 segundos (NAO recomendado para o Protheus)\n");
	printf("Ruim    - ate 25.000000 segundos (NAO recomendado para o Protheus)\n");
	printf("Pessimo -   + 25.000000 segundos (NAO recomendado para o Protheus)\n");
	printf(" \n");

	printf(" TABELA DE REFERENCIA - LEITURA EM DISCO\n");
	printf(" \n");
	printf("Otimo   - ate 10.000000 segundos (RECOMENDADO PARA O PROTHEUS)\n");
	printf("Bom     - ate 25.000000 segundos (NAO recomendado para o Protheus)\n");
	printf("Ruim    - ate 26.000000 segundos (NAO recomendado para o Protheus)\n");
	printf("Pessimo -   + 26.000000 segundos (NAO recomendado para o Protheus)\n");
	printf(" \n");
}
Expandir
titleUtilizando o MallocIO

Em modo DOS, acesse o diretório do executável e execute o mesmo. Aparecerá a seguinte tela:

Image RemovedImage Added


ALOCANDO BLOCO DE MEMÓRIA

Representa o momento de início e de final da alocação do bloco de memória. Como resposta, aparecerá o tempo de execução.

Tempo para alocar bloco de memória:

20.000000 24.000000 29.000000 30.000000

Até

10s

Ótimo

Até

15s

Bom

Até

26s

Ruim

Acima de

26s

Péssimo


LEITURA EM DISCO

Representa o momento de início e final de leitura em de um arquivo .txt. Verifique na tabela de referência se o resultado será adequado para o Protheus.

Tempo de leitura do arquivo teste:

.000000 25.000000 .000000 40.000000

Até 10

segundos

Ótimo

Até

segundos

Bom

Até 26

segundos

Ruim

Acima de

26 segundos

Péssimo