Compare commits

..

1 Commits
main ... main

Author SHA1 Message Date
fd8ce04a1a remarque.txt ajout 2024-09-03 12:18:42 +02:00
5 changed files with 44 additions and 3 deletions

View File

@ -11,11 +11,19 @@ void bubblesort(int* array, int length)
{
if(array[i-1] > array[i])
{
tmp = array[i-1];
/*tmp = array[i-1];
array[i-1] = array[i];
array[i] = tmp;
array[i] = tmp;*/
swap(array[i-1],array[i]);
swapped++;
}
}
} while(swapped==1);
}
void swap(int a, int b)
{
int temp = a;
a = b;
b = temp;
}

BIN
gmon.out Normal file

Binary file not shown.

32
remarques.txt Normal file
View File

@ -0,0 +1,32 @@
Test 1:
gcc -g -pg -o student_rank student_rank.c heapsort.c bubblesort.c
./student_rank 5 5 1
gprof ./student_rank
Suite a la première analyse avec gprof, on observe que le programme s'est executé pratiquement instantanément, et que aucun temps n'a été utilisé par aucune fonction.
Test 2:
./student_rank 1000 5 1
gprof ./student_rank
Suite à la deuxieme analyse, on voit que du temps a été utilisé. cependant il est tellement infime, que gprof indique une utilisation de 100% du temps pour la fonction bublesort et sortstudent.
Test 3:
./student_rank 1000 1000 0
gprof ./student_rank
suite a cette troiseme tentative, on note qu'une différence commence a se créer dans les fonctions.
bublesort utilise 80.56% du temps d'execution, et find_rank_student 19.61%.
tout le reste n'est que peu consomateur de temps.
durée 28s
gprof -b ./student_rank
Profiling:
Puisque bublesort est appelé de nombreuse fois, o peux essayer de diminuer le nombre d'appel.
On remarque alors que l'appel de bubblesort dan sla fonction find rank est innutile et peut donc la supprimé.
la durée passe alors à 0.5s

BIN
student_rank Executable file

Binary file not shown.

View File

@ -55,7 +55,7 @@ int find_rank_student(int student_grade, int* grades_array, int students_number)
{
int position = -1;
int i = 0;
bubblesort(grades_array,students_number);
//bubblesort(grades_array,students_number);
for(i = students_number-1; i >= 0; i--)
{
if(grades_array[i] == student_grade)
@ -78,6 +78,7 @@ void sort_students(int** students_rank, int** students_array, int students_numbe
grades[j] = students_array[j][i];
}
bubblesort(grades,students_number);
//heapsort(grades,students_number);
for(j = 0; j < students_number; j++)
{
students_rank[j][i] = find_rank_student(students_array[j][i],grades,students_number);