commit 6565163d112807639d5170cacd8c5a37b481547a Author: gallego Date: Wed Oct 15 16:26:07 2025 +0200 finie ! diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..c0fd1a0 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "files.associations": { + "time.h": "c", + "stdio.h": "c", + "stdlib.h": "c" + } +} \ No newline at end of file diff --git a/Exo1.c b/Exo1.c new file mode 100644 index 0000000..af81e75 --- /dev/null +++ b/Exo1.c @@ -0,0 +1,35 @@ +#include + +TAILLE_TAB = 10000; + +int racineCarree(int n){ + if (n < 0){ + return -2; + } + for(int i = 0; i +#include +#include + + +int TAILLE_TAB = 10000; + +int racineCarree(int n){ + if (n < 0){ + return -2; + } + for(int i = 0; i +#include +#include +int TAILLE_TAB = 4; + +int racineCarree(int n){ + if (n < 0){ + return -2; + } + for(int i = 0; i +[3] 100.0 0.00 13.59 main [3] + 0.00 13.59 1/1 racineCarreeTab [2] +----------------------------------------------- + +complexité cyclomatique + +racineCarree() = 5 +racineCarreeTab() = 2 + +Complexité algorithmique + +racineCarree() = O(n) +racineCarreeTab() = O(t*n) avec t = taille du tableau + +Exercice 3 + +Pour compiler : gcc -pg -std=c99 Exo3.c + +Exercice 4 + +Pour profiler avec gprof on entre la commande gprof ./a.out après avoir compiler le code + +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 6 0.00 0.00 racineCarree + 0.00 0.00 0.00 1 0.00 0.00 TriSpecial + +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 6/6 TriSpecial [2] +[1] 0.0 0.00 0.00 6 racineCarree [1] +----------------------------------------------- + 0.00 0.00 1/1 main [6] +[2] 0.0 0.00 0.00 1 TriSpecial [2] + 0.00 0.00 6/6 racineCarree [1] +----------------------------------------------- + +La complexité cyclomatique de TriSpecial() est de 10 +La complexité algorithmique de TriSpecial() est O(t*n) avec t la taille du tableau \ No newline at end of file diff --git a/gmon.out b/gmon.out new file mode 100644 index 0000000..e12c16e Binary files /dev/null and b/gmon.out differ