forked from menault/TD2_DEV51_Qualite_Algo
travail
This commit is contained in:
@@ -13,7 +13,7 @@ Pour chaque fonction, un diagramme est proposé dans ping-report/diagrammes/*nom
|
||||
- write_pid_file() : 2
|
||||
- get_ping_from_temp_log : 12
|
||||
- write_ping_log : 3
|
||||
- ste_stats_ping() : 10
|
||||
- set_stats_ping() : 10
|
||||
|
||||
Toute fonction non mentionnée dans la liste a une complexité cyclomatique de 1, et donc ne nécessite pas un diagramme.
|
||||
|
||||
@@ -126,4 +126,40 @@ char* better_get_ping_from_temp_log(){
|
||||
}
|
||||
```
|
||||
|
||||
Vous pouvez retrouver le diagramme dans le répertoire ping-report/diagrammes/better_get_ping_from_temp_log.mdj. La complexité cyclomatique de l'algorithme sous cette forme est de 7.
|
||||
Vous pouvez retrouver le diagramme dans le répertoire ping-report/diagrammes/better_get_ping_from_temp_log.mdj. La complexité cyclomatique de l'algorithme sous cette forme est de 7.
|
||||
|
||||
On peut appliquer le même principe à set_stats_ping en factorisant le segment suivant de la fonction :
|
||||
|
||||
```c
|
||||
void trop_de_ifs(char* read_line, int* nb_loss, double* ping, int* nb_ping, double* max, double* min, int* nb_high, double* sum){
|
||||
if(strcmp(read_line,"LOSS") == 0){
|
||||
(*nb_loss)++;
|
||||
}else{
|
||||
/* Evaluate the ping as a double */
|
||||
*ping = strtod(read_line,NULL);
|
||||
/* Test null ping */
|
||||
if(*ping < 0.1){
|
||||
/* Ignore null ping */
|
||||
}else{
|
||||
/* Number of ping readed (for mean calculation) */
|
||||
*nb_ping++;
|
||||
/* Max ping */
|
||||
if(*ping > *max){
|
||||
*max = *ping;
|
||||
}
|
||||
/* Min ping */
|
||||
if(*ping < *min){
|
||||
*min = *ping;
|
||||
}
|
||||
/* Number of ping above 100 ms */
|
||||
if(*ping > 100.0){
|
||||
*nb_high++;
|
||||
}
|
||||
/* Sum (for mean calculation) */
|
||||
sum += *ping;
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Vous pouvez retrouver le diagramme dans le répertoire ping-report/diagrammes/better_set_stats_ping. La complexité cyclomatique de l'algorithme sous cette forme est de 4.
|
||||
|
1
ping-report/diagrammes/better_set_stats_ping.mdj
Normal file
1
ping-report/diagrammes/better_set_stats_ping.mdj
Normal file
File diff suppressed because one or more lines are too long
@@ -270,6 +270,36 @@ void write_ping_log(char* new_ping){
|
||||
Return value :
|
||||
None
|
||||
*/
|
||||
void trop_de_ifs(char* read_line, int* nb_loss, double* ping, int* nb_ping, double* max, double* min, int* nb_high, double* sum){
|
||||
if(strcmp(read_line,"LOSS") == 0){
|
||||
(*nb_loss)++;
|
||||
}else{
|
||||
/* Evaluate the ping as a double */
|
||||
*ping = strtod(read_line,NULL);
|
||||
/* Test null ping */
|
||||
if(*ping < 0.1){
|
||||
/* Ignore null ping */
|
||||
}else{
|
||||
/* Number of ping readed (for mean calculation) */
|
||||
*nb_ping++;
|
||||
/* Max ping */
|
||||
if(*ping > *max){
|
||||
*max = *ping;
|
||||
}
|
||||
/* Min ping */
|
||||
if(*ping < *min){
|
||||
*min = *ping;
|
||||
}
|
||||
/* Number of ping above 100 ms */
|
||||
if(*ping > 100.0){
|
||||
*nb_high++;
|
||||
}
|
||||
/* Sum (for mean calculation) */
|
||||
sum += *ping;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void set_stats_ping(){
|
||||
|
||||
/* Variables */
|
||||
|
Reference in New Issue
Block a user