forked from menault/TD2_DEV51_Qualite_Algo
Damien Riera - Tom Momméja - Gaston Chenet
This commit is contained in:
92
compte-rendu.md
Normal file
92
compte-rendu.md
Normal file
@@ -0,0 +1,92 @@
|
||||
# Damien Riera - Tom Momméja - Gaston Chenet
|
||||
|
||||
## daemon.c
|
||||
|
||||
### create_daemon()
|
||||
|
||||
cette fonction a une complexité de 4
|
||||
|
||||
### ping_request()
|
||||
|
||||
Cette fonction a une complexité de 2
|
||||
|
||||
### send_check()
|
||||
|
||||
Cette fonction a une complexité de 3
|
||||
|
||||
### check_keep_working()
|
||||
|
||||
Cette fonction a une complexité de 4
|
||||
|
||||
### daemon_work()
|
||||
|
||||
Cette fonction a une complexité de 3
|
||||
|
||||
## db-sqlite.c
|
||||
|
||||
### db_connect() - db_disconnect() - insert_hourly_report()
|
||||
|
||||
Toutes ces fonctions ont une complexité de 1
|
||||
|
||||
## ping-report.c
|
||||
|
||||
### main()
|
||||
|
||||
Cette fonction a une complexité de 4
|
||||
|
||||
## stats.c
|
||||
|
||||
### get_ping_from_temp_log()
|
||||
|
||||
Cette fonction a une complexité de 8
|
||||
|
||||

|
||||
|
||||
### write_ping_log()
|
||||
|
||||
Cette fonction a une complexité de 4
|
||||
|
||||
### set_stats_ping()
|
||||
|
||||
Cette fonction a une complexité de 9
|
||||
|
||||

|
||||
|
||||
## utils.c
|
||||
|
||||
### write_pid_file()
|
||||
|
||||
Cette fonction a une commplexité de 2
|
||||
|
||||
### remove_file()
|
||||
|
||||
Cette fonction a une complexité de 1
|
||||
|
||||
# Réduire la complexité de set_stats_ping()
|
||||
|
||||
```c
|
||||
/* Check if the ping is flagged as LOSS */
|
||||
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 */
|
||||
}
|
||||
/* ... */
|
||||
}
|
||||
```
|
||||
|
||||
à:
|
||||
|
||||
```c
|
||||
/* Evaluate the ping as a double */
|
||||
ping = strtod(read_line,NULL);
|
||||
/* Check if the ping is flagged as LOSS */
|
||||
if(strcmp(read_line,"LOSS") == 0 && ping < 0.1){
|
||||
nb_loss++;
|
||||
}
|
||||
/* ... */
|
||||
```
|
BIN
images/get_ping_from_temp_log.webp
Normal file
BIN
images/get_ping_from_temp_log.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
BIN
images/set_stats_ping.png
Normal file
BIN
images/set_stats_ping.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 53 KiB |
@@ -198,16 +198,11 @@ void set_stats_ping(){
|
||||
if(read_line == NULL){
|
||||
break;
|
||||
}
|
||||
|
||||
/* Check if the ping is flagged as LOSS */
|
||||
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 */
|
||||
/* Check if the ping is flagged as LOSS */
|
||||
if(strcmp(read_line,"LOSS") == 0 && ping < 0.1){
|
||||
nb_loss++;
|
||||
}else{
|
||||
/* Number of ping readed (for mean calculation) */
|
||||
nb_ping++;
|
||||
@@ -226,7 +221,6 @@ void set_stats_ping(){
|
||||
/* Sum (for mean calculation) */
|
||||
sum += ping;
|
||||
}
|
||||
}
|
||||
free(read_line);
|
||||
n = 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user