Jump to content

Recommended Posts

Posted

Pentru măsurarea timpului de execuție se poate adapta următorul cod după nevoi:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
	clock_t start, finish;
	long loop;
	double result, r2, elapsed_time;
	printf("Inmultirea a doua numere reale de un miliard de ori...\n");
	result = 3.1415926535897;
	start = clock(); //inceputul experimentului
	for (loop = 0; loop < 1000000000; loop++) {
		r2 = result*16.0;
	}
	finish = clock(); //sfarsitul operatiilor cronometrate
	elapsed_time = (double)(finish - start) / CLOCKS_PER_SEC;
	printf("\nProgramul necesita %6.2f secunde.\n", elapsed_time);
	return 0;
}

Pentru eficiență ca spațiu de memorie ocupat: https://stackoverflow.com/questions/10443131/how-much-memory-a-c-c-program-is-using

  • Like 1

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.