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,34 +198,28 @@ void set_stats_ping(){
|
|||||||
if(read_line == NULL){
|
if(read_line == NULL){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
/* Evaluate the ping as a double */
|
||||||
|
ping = strtod(read_line,NULL);
|
||||||
/* Check if the ping is flagged as LOSS */
|
/* Check if the ping is flagged as LOSS */
|
||||||
if(strcmp(read_line,"LOSS") == 0){
|
if(strcmp(read_line,"LOSS") == 0 && ping < 0.1){
|
||||||
nb_loss++;
|
nb_loss++;
|
||||||
}else{
|
}else{
|
||||||
/* Evaluate the ping as a double */
|
/* Number of ping readed (for mean calculation) */
|
||||||
ping = strtod(read_line,NULL);
|
nb_ping++;
|
||||||
/* Test null ping */
|
/* Max ping */
|
||||||
if(ping < 0.1){
|
if(ping > max){
|
||||||
/* Ignore null ping */
|
max = 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;
|
|
||||||
}
|
}
|
||||||
|
/* 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;
|
||||||
}
|
}
|
||||||
free(read_line);
|
free(read_line);
|
||||||
n = 0;
|
n = 0;
|
||||||
|
Reference in New Issue
Block a user