From 92611bea55c3f96f84b36a86b82faf22a3bdbdb4 Mon Sep 17 00:00:00 2001 From: Axel Pietrois Date: Tue, 3 Sep 2024 12:06:21 +0200 Subject: [PATCH] :) --- Notes.md | 37 ++++++++++ gmon.out | Bin 0 -> 3765 bytes gprof1.txt | 183 +++++++++++++++++++++++++++++++++++++++++++++++++ gprof2.txt | 179 +++++++++++++++++++++++++++++++++++++++++++++++ gprof3.txt | 58 ++++++++++++++++ student_rank | Bin 0 -> 21864 bytes student_rank.c | 31 ++++----- 7 files changed, 472 insertions(+), 16 deletions(-) create mode 100644 Notes.md create mode 100644 gmon.out create mode 100644 gprof1.txt create mode 100644 gprof2.txt create mode 100644 gprof3.txt create mode 100755 student_rank diff --git a/Notes.md b/Notes.md new file mode 100644 index 0000000..50cb44e --- /dev/null +++ b/Notes.md @@ -0,0 +1,37 @@ +# Compte rendu + +```bash +gcc -g -pg -o student_rank student_rank.c heapsort.c bubblesort.c +``` + +```bash +./student_rank 5 5 1 +``` + +```bash +gprof ./student_rank +``` +Utilisation de gprof : +Après l'utilisation du -pg dans la compilation et le mode debug a 1 à l'execution, gprof [executable] + + +gprof1.txt -> ./student_rank 5 5 1 +gprof2.txt -> ./student_rank 1000 1000 0 +gprof3.txt -> ./student_rank 1000 10000 0 + +index % time self children called name + 0.00 0.00 5/30 sort_students [9] + 0.00 0.00 25/30 find_rank_student [2] +[1] 0.0 0.00 0.00 30 bubblesort [1] +----------------------------------------------- + 0.00 0.00 25/25 sort_students [9] +[2] 0.0 0.00 0.00 25 find_rank_student [2] + 0.00 0.00 25/30 bubblesort [1] +----------------------------------------------- + + +Bubblesort prend le + de temps à s'executer + +Le bubblesort ligne 58 est inefficace et s'execute trop souvent car il trie un array deja trié + +Le heapsort n'est pas plus optimisé dans ce cas là diff --git a/gmon.out b/gmon.out new file mode 100644 index 0000000000000000000000000000000000000000..6091895868791048881e45c8f687aba4b3314df3 GIT binary patch literal 3765 zcmYe#&Cg?GzyYR6LnL0XF)*Y6nZ>Ee`FSbDFx7AdOkk8A4S~@R7!85Z5Eu=C(GVC7 zfzc44cL*?nEd({_KrEaMJ9;|{%|2!@A4IAEF*j6}3G8Mlhe8V2U?l=T+<{9Wac1Ds zJt{sL0{BCKk?8ae$<;8^NXgX@wZ!URoFD|TLct8xo(SRBQvX}7zRB$u0;0LJS8mM-#N&|6-_IP0k4Hk63A_xGbC=@OL literal 0 HcmV?d00001 diff --git a/gprof1.txt b/gprof1.txt new file mode 100644 index 0000000..2f03923 --- /dev/null +++ b/gprof1.txt @@ -0,0 +1,183 @@ +Flat profile: + +Each sample counts as 0.01 seconds. + no time accumulated + + % cumulative self self total + time seconds seconds calls Ts/call Ts/call name + 0.00 0.00 0.00 30 0.00 0.00 bubblesort + 0.00 0.00 0.00 25 0.00 0.00 find_rank_student + 0.00 0.00 0.00 10 0.00 0.00 print_array + 0.00 0.00 0.00 5 0.00 0.00 generate_array + 0.00 0.00 0.00 2 0.00 0.00 free_array + 0.00 0.00 0.00 2 0.00 0.00 print_student_array + 0.00 0.00 0.00 1 0.00 0.00 generate_grades + 0.00 0.00 0.00 1 0.00 0.00 generate_ranks + 0.00 0.00 0.00 1 0.00 0.00 sort_students + + % the percentage of the total running time of the +time program used by this function. + +cumulative a running sum of the number of seconds accounted + seconds for by this function and those listed above it. + + self the number of seconds accounted for by this +seconds function alone. This is the major sort for this + listing. + +calls the number of times this function was invoked, if + this function is profiled, else blank. + + self the average number of milliseconds spent in this +ms/call function per call, if this function is profiled, + else blank. + + total the average number of milliseconds spent in this +ms/call function and its descendents per call, if this + function is profiled, else blank. + +name the name of the function. This is the minor sort + for this listing. The index shows the location of + the function in the gprof listing. If the index is + in parenthesis it shows where it would appear in + the gprof listing if it were to be printed. + +Copyright (C) 2012-2023 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + + Call graph (explanation follows) + + +granularity: each sample hit covers 2 byte(s) no time propagated + +index % time self children called name + 0.00 0.00 5/30 sort_students [9] + 0.00 0.00 25/30 find_rank_student [2] +[1] 0.0 0.00 0.00 30 bubblesort [1] +----------------------------------------------- + 0.00 0.00 25/25 sort_students [9] +[2] 0.0 0.00 0.00 25 find_rank_student [2] + 0.00 0.00 25/30 bubblesort [1] +----------------------------------------------- + 0.00 0.00 10/10 print_student_array [6] +[3] 0.0 0.00 0.00 10 print_array [3] +----------------------------------------------- + 0.00 0.00 5/5 generate_grades [7] +[4] 0.0 0.00 0.00 5 generate_array [4] +----------------------------------------------- + 0.00 0.00 2/2 main [14] +[5] 0.0 0.00 0.00 2 free_array [5] +----------------------------------------------- + 0.00 0.00 2/2 main [14] +[6] 0.0 0.00 0.00 2 print_student_array [6] + 0.00 0.00 10/10 print_array [3] +----------------------------------------------- + 0.00 0.00 1/1 main [14] +[7] 0.0 0.00 0.00 1 generate_grades [7] + 0.00 0.00 5/5 generate_array [4] +----------------------------------------------- + 0.00 0.00 1/1 main [14] +[8] 0.0 0.00 0.00 1 generate_ranks [8] +----------------------------------------------- + 0.00 0.00 1/1 main [14] +[9] 0.0 0.00 0.00 1 sort_students [9] + 0.00 0.00 25/25 find_rank_student [2] + 0.00 0.00 5/30 bubblesort [1] +----------------------------------------------- + + This table describes the call tree of the program, and was sorted by + the total amount of time spent in each function and its children. + + Each entry in this table consists of several lines. The line with the + index number at the left hand margin lists the current function. + The lines above it list the functions that called this function, + and the lines below it list the functions this one called. + This line lists: + index A unique number given to each element of the table. + Index numbers are sorted numerically. + The index number is printed next to every function name so + it is easier to look up where the function is in the table. + + % time This is the percentage of the `total' time that was spent + in this function and its children. Note that due to + different viewpoints, functions excluded by options, etc, + these numbers will NOT add up to 100%. + + self This is the total amount of time spent in this function. + + children This is the total amount of time propagated into this + function by its children. + + called This is the number of times the function was called. + If the function called itself recursively, the number + only includes non-recursive calls, and is followed by + a `+' and the number of recursive calls. + + name The name of the current function. The index number is + printed after it. If the function is a member of a + cycle, the cycle number is printed between the + function's name and the index number. + + + For the function's parents, the fields have the following meanings: + + self This is the amount of time that was propagated directly + from the function into this parent. + + children This is the amount of time that was propagated from + the function's children into this parent. + + called This is the number of times this parent called the + function `/' the total number of times the function + was called. Recursive calls to the function are not + included in the number after the `/'. + + name This is the name of the parent. The parent's index + number is printed after it. If the parent is a + member of a cycle, the cycle number is printed between + the name and the index number. + + If the parents of the function cannot be determined, the word + `' is printed in the `name' field, and all the other + fields are blank. + + For the function's children, the fields have the following meanings: + + self This is the amount of time that was propagated directly + from the child into the function. + + children This is the amount of time that was propagated from the + child's children to the function. + + called This is the number of times the function called + this child `/' the total number of times the child + was called. Recursive calls by the child are not + listed in the number after the `/'. + + name This is the name of the child. The child's index + number is printed after it. If the child is a + member of a cycle, the cycle number is printed + between the name and the index number. + + If there are any cycles (circles) in the call graph, there is an + entry for the cycle-as-a-whole. This entry shows who called the + cycle (as parents) and the members of the cycle (as children.) + The `+' recursive calls entry shows the number of function calls that + were internal to the cycle, and the calls entry for each member shows, + for that member, how many times it was called from other members of + the cycle. + +Copyright (C) 2012-2023 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Index by function name + + [1] bubblesort [4] generate_array [3] print_array + [2] find_rank_student [7] generate_grades [6] print_student_array + [5] free_array [8] generate_ranks [9] sort_students diff --git a/gprof2.txt b/gprof2.txt new file mode 100644 index 0000000..be919ef --- /dev/null +++ b/gprof2.txt @@ -0,0 +1,179 @@ +Flat profile: + +Each sample counts as 0.01 seconds. + % cumulative self self total + time seconds seconds calls s/call s/call name + 80.87 3.32 3.32 1001000 0.00 0.00 bubblesort + 18.57 4.08 0.76 1000000 0.00 0.00 find_rank_student + 0.49 4.10 0.02 1 0.02 4.10 sort_students + 0.24 4.11 0.01 1 0.01 0.01 generate_ranks + 0.00 4.11 0.00 1000 0.00 0.00 generate_array + 0.00 4.11 0.00 2 0.00 0.00 free_array + 0.00 4.11 0.00 1 0.00 0.00 generate_grades + + % the percentage of the total running time of the +time program used by this function. + +cumulative a running sum of the number of seconds accounted + seconds for by this function and those listed above it. + + self the number of seconds accounted for by this +seconds function alone. This is the major sort for this + listing. + +calls the number of times this function was invoked, if + this function is profiled, else blank. + + self the average number of milliseconds spent in this +ms/call function per call, if this function is profiled, + else blank. + + total the average number of milliseconds spent in this +ms/call function and its descendents per call, if this + function is profiled, else blank. + +name the name of the function. This is the minor sort + for this listing. The index shows the location of + the function in the gprof listing. If the index is + in parenthesis it shows where it would appear in + the gprof listing if it were to be printed. + +Copyright (C) 2012-2023 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + + Call graph (explanation follows) + + +granularity: each sample hit covers 2 byte(s) for 0.24% of 4.11 seconds + +index % time self children called name + +[1] 100.0 0.00 4.11 main [1] + 0.02 4.08 1/1 sort_students [2] + 0.01 0.00 1/1 generate_ranks [5] + 0.00 0.00 2/2 free_array [7] + 0.00 0.00 1/1 generate_grades [8] +----------------------------------------------- + 0.02 4.08 1/1 main [1] +[2] 99.8 0.02 4.08 1 sort_students [2] + 0.76 3.31 1000000/1000000 find_rank_student [3] + 0.00 0.00 1000/1001000 bubblesort [4] +----------------------------------------------- + 0.76 3.31 1000000/1000000 sort_students [2] +[3] 99.2 0.76 3.31 1000000 find_rank_student [3] + 3.31 0.00 1000000/1001000 bubblesort [4] +----------------------------------------------- + 0.00 0.00 1000/1001000 sort_students [2] + 3.31 0.00 1000000/1001000 find_rank_student [3] +[4] 80.7 3.32 0.00 1001000 bubblesort [4] +----------------------------------------------- + 0.01 0.00 1/1 main [1] +[5] 0.2 0.01 0.00 1 generate_ranks [5] +----------------------------------------------- + 0.00 0.00 1000/1000 generate_grades [8] +[6] 0.0 0.00 0.00 1000 generate_array [6] +----------------------------------------------- + 0.00 0.00 2/2 main [1] +[7] 0.0 0.00 0.00 2 free_array [7] +----------------------------------------------- + 0.00 0.00 1/1 main [1] +[8] 0.0 0.00 0.00 1 generate_grades [8] + 0.00 0.00 1000/1000 generate_array [6] +----------------------------------------------- + + This table describes the call tree of the program, and was sorted by + the total amount of time spent in each function and its children. + + Each entry in this table consists of several lines. The line with the + index number at the left hand margin lists the current function. + The lines above it list the functions that called this function, + and the lines below it list the functions this one called. + This line lists: + index A unique number given to each element of the table. + Index numbers are sorted numerically. + The index number is printed next to every function name so + it is easier to look up where the function is in the table. + + % time This is the percentage of the `total' time that was spent + in this function and its children. Note that due to + different viewpoints, functions excluded by options, etc, + these numbers will NOT add up to 100%. + + self This is the total amount of time spent in this function. + + children This is the total amount of time propagated into this + function by its children. + + called This is the number of times the function was called. + If the function called itself recursively, the number + only includes non-recursive calls, and is followed by + a `+' and the number of recursive calls. + + name The name of the current function. The index number is + printed after it. If the function is a member of a + cycle, the cycle number is printed between the + function's name and the index number. + + + For the function's parents, the fields have the following meanings: + + self This is the amount of time that was propagated directly + from the function into this parent. + + children This is the amount of time that was propagated from + the function's children into this parent. + + called This is the number of times this parent called the + function `/' the total number of times the function + was called. Recursive calls to the function are not + included in the number after the `/'. + + name This is the name of the parent. The parent's index + number is printed after it. If the parent is a + member of a cycle, the cycle number is printed between + the name and the index number. + + If the parents of the function cannot be determined, the word + `' is printed in the `name' field, and all the other + fields are blank. + + For the function's children, the fields have the following meanings: + + self This is the amount of time that was propagated directly + from the child into the function. + + children This is the amount of time that was propagated from the + child's children to the function. + + called This is the number of times the function called + this child `/' the total number of times the child + was called. Recursive calls by the child are not + listed in the number after the `/'. + + name This is the name of the child. The child's index + number is printed after it. If the child is a + member of a cycle, the cycle number is printed + between the name and the index number. + + If there are any cycles (circles) in the call graph, there is an + entry for the cycle-as-a-whole. This entry shows who called the + cycle (as parents) and the members of the cycle (as children.) + The `+' recursive calls entry shows the number of function calls that + were internal to the cycle, and the calls entry for each member shows, + for that member, how many times it was called from other members of + the cycle. + +Copyright (C) 2012-2023 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Index by function name + + [4] bubblesort [6] generate_array [2] sort_students + [3] find_rank_student [8] generate_grades + [7] free_array [5] generate_ranks diff --git a/gprof3.txt b/gprof3.txt new file mode 100644 index 0000000..42159be --- /dev/null +++ b/gprof3.txt @@ -0,0 +1,58 @@ +Flat profile: + +Each sample counts as 0.01 seconds. + % cumulative self self total + time seconds seconds calls s/call s/call name + 80.61 34.07 34.07 10010000 0.00 0.00 bubblesort + 18.16 41.74 7.67 10000000 0.00 0.00 find_rank_student + 0.92 42.13 0.39 1 0.39 42.13 sort_students + 0.33 42.27 0.14 1000 0.00 0.00 generate_array + 0.14 42.33 0.06 1 0.06 0.06 generate_ranks + 0.00 42.33 0.00 2 0.00 0.00 free_array + 0.00 42.33 0.00 1 0.00 0.14 generate_grades + + Call graph + + +granularity: each sample hit covers 2 byte(s) for 0.02% of 42.33 seconds + +index % time self children called name + +[1] 100.0 0.00 42.33 main [1] + 0.39 41.74 1/1 sort_students [2] + 0.00 0.14 1/1 generate_grades [6] + 0.06 0.00 1/1 generate_ranks [7] + 0.00 0.00 2/2 free_array [8] +----------------------------------------------- + 0.39 41.74 1/1 main [1] +[2] 99.5 0.39 41.74 1 sort_students [2] + 7.67 34.03 10000000/10000000 find_rank_student [3] + 0.03 0.00 10000/10010000 bubblesort [4] +----------------------------------------------- + 7.67 34.03 10000000/10000000 sort_students [2] +[3] 98.5 7.67 34.03 10000000 find_rank_student [3] + 34.03 0.00 10000000/10010000 bubblesort [4] +----------------------------------------------- + 0.03 0.00 10000/10010000 sort_students [2] + 34.03 0.00 10000000/10010000 find_rank_student [3] +[4] 80.5 34.07 0.00 10010000 bubblesort [4] +----------------------------------------------- + 0.14 0.00 1000/1000 generate_grades [6] +[5] 0.3 0.14 0.00 1000 generate_array [5] +----------------------------------------------- + 0.00 0.14 1/1 main [1] +[6] 0.3 0.00 0.14 1 generate_grades [6] + 0.14 0.00 1000/1000 generate_array [5] +----------------------------------------------- + 0.06 0.00 1/1 main [1] +[7] 0.1 0.06 0.00 1 generate_ranks [7] +----------------------------------------------- + 0.00 0.00 2/2 main [1] +[8] 0.0 0.00 0.00 2 free_array [8] +----------------------------------------------- + +Index by function name + + [4] bubblesort [5] generate_array [2] sort_students + [3] find_rank_student [6] generate_grades + [8] free_array [7] generate_ranks diff --git a/student_rank b/student_rank new file mode 100755 index 0000000000000000000000000000000000000000..7e19f9b385b4942c9c12e92dc30bf3b9945f37d5 GIT binary patch literal 21864 zcmeHPdvH|Oc|UhoM_RoXfj~TLEiW6eSxLMM2Ep=JSU?zTOO9}GmPNagw$`h=D-0>b z*aF+@HL>u-4oyiyoHX&IFHe(cC{7yjsKKtAAqjEFjN>XUZbhLniAkb3)Z5>89=rEm zX)|s+ndu)oJA1$LJ&0?G35|;A2Z!DYmoN zOqLHkPtYXaCjq#!Tyj{UOVOQxq*q0iQQ$O5W*TY_36fr}a#S^-AyfSzJx)prx5FdF z(xQf%pJ~q{`OF5JmH!%=^(Zzc=1aX3^;Y;56_=M4)Ov)H-g%{WUg>E#NDiTBsN+d7 zq5o3lj~)8Jqv8`=#_W1~l%5@~Q}P;88&vLpHxd5dw6{&^9rXw^%nm;z$xK7t-o4PH zxO~*2hxtC$UaoNnsQ7EB!pmwpqPvzXs_6*N?}&Ew?wP-5>5}haUZIc>Y0> zp?;7}lA%I0`s+eG{nxaQ0=Ge^Vidt0Iq1`K(7yn>2Y-9n48myk!#U{GhtcGh=Af_4 zL4P<0eM$~GMRl}xdveeh=AfSh-Gjfq&~9ahod|px{-d?af}JfLkx*A}4+{oc_Jo41 z(XLQO^pg?R8S3chZUGgU*%FK=La{`!GZgJ&p+t9-#bcqaFqoa)U4jMup58>9wZFtSW3zJzUP*tlkGaDjK>qD*yxcQFfY zY}^tIM`Dq-Xgm>#HEvnk(cKkk4DITGCE|_BVa$P_6M0I|{*zSN?ng{0->H1_$P1Y6 zPWB|~MC+XrEhIb75fer4PxXGxt%5nA_LrJIFiy&E^GT@b8h>e(q|?4d?E(eiWfR>z z-%gn51yWUP2TXK0nknZ^^pXsfu?r@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5(= 0; i--) - { - if(grades_array[i] == student_grade) - { + // bubblesort(grades_array,students_number); + for(i = students_number-1; i >= 0; i--) { + + if(grades_array[i] == student_grade) { position = students_number-i; - break; - } + break; + } } return position; } @@ -73,16 +72,16 @@ void sort_students(int** students_rank, int** students_array, int students_numbe for(i = 0; i < grades_number; i++) { int * grades = (int*) malloc(students_number*sizeof(int)); - for(j = 0; j < students_number; j++) - { - grades[j] = students_array[j][i]; - } - bubblesort(grades,students_number); - for(j = 0; j < students_number; j++) - { + for(j = 0; j < students_number; j++) + { + grades[j] = students_array[j][i]; + } + bubblesort(grades,students_number); + for(j = 0; j < students_number; j++) + { students_rank[j][i] = find_rank_student(students_array[j][i],grades,students_number); - } - free(grades); + } + free(grades); } }