-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.c
121 lines (105 loc) · 3.9 KB
/
test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//
// Created by MehdiRbk on 10/12/2023.
//
#include "test.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "level_list.h"
#include "timer.h"
#import "schedule.h"
void testpart1and2(){
printf("Ajout en tête de liste\n");
t_level_list MyLevelList = createLevelList(5);
displayLevelList(MyLevelList);
addHeadLevelList(&MyLevelList,createLevelCell(18,3));
displayLevelList(MyLevelList);
addHeadLevelList(&MyLevelList,createLevelCell(12,4));
displayLevelList(MyLevelList);
addHeadLevelList(&MyLevelList,createLevelCell(19,1));
displayLevelList(MyLevelList);
addHeadLevelList(&MyLevelList,createLevelCell(90,8));
displayLevelList(MyLevelList);
printf("Ajout en ordre croissant\n");
//Ajout en ordre croissant
t_level_list MyLevelList2 = createLevelList(8);
displayLevelList(MyLevelList2);
addOrderLevelList(&MyLevelList2,createLevelCell(20,5));
displayLevelList(MyLevelList2);
addOrderLevelList(&MyLevelList2,createLevelCell(35,2));
displayLevelList(MyLevelList2);
addOrderLevelList(&MyLevelList2,createLevelCell(10,3));
displayLevelList(MyLevelList2);
addOrderLevelList(&MyLevelList2, createLevelCell(25,1));
displayLevelList(MyLevelList2);
addOrderLevelList(&MyLevelList2,createLevelCell(59,9));
displayLevelList(MyLevelList2);
addOrderLevelList(&MyLevelList2,createLevelCell(1,8));
displayLevelList(MyLevelList2);
printf("Trouver un élément dans la liste\n");
t_level_list MyLevelList2N = createSorted2NLevelList(4);
displayLevelList(MyLevelList2N);
p_level_cell find= searchValInFirstLevel(MyLevelList2N,1);
if( find !=NULL)
{
printf("FIND");
}
else
printf("NOT FIND");
printf("Calcul de comparaison entre les deux recherches\n");
//code pour calculer le temps de chaque recherche.
int random_value,max;
p_level_cell findcell;
FILE *log_file = fopen("log.txt","w");
char format[] = "%d\t%s\t%s\n" ;
int level=7;
char *time_lvl0;
char *time_all_levels;
t_level_list test_list;
while (level <=15)
{
test_list= createSorted2NLevelList(level);
startTimer();
max = (int) pow(2,level)-1;
for (int i = 0; i< 10000;i++)
{
random_value = (int) rand()%( max+1 );
findcell = searchValInFirstLevel(test_list,random_value);
}
stopTimer();
displayTime();
time_lvl0 = getTimeAsString(); // fonction du module timer
startTimer();
for (int i = 0; i< 10000;i++)
{
random_value = (int) rand()%( max+1 );
findcell = searchValInList(test_list,random_value);
}
stopTimer();
time_all_levels = getTimeAsString();
displayTime();
fprintf(log_file,format,level,time_lvl0, time_all_levels);
level++;
}
fclose(log_file);
}
void testpart3(){
t_contact_schedule* ContactSchedule1 = createContactSchedule();
insertNewAppointmentforContact(ContactSchedule1);
insertNewAppointmentforContact(ContactSchedule1);
insertNewAppointmentforContact(ContactSchedule1);
displayContactAppointment(*ContactSchedule1);
printf("Suppression du rendez-vous numéro 2\n");
//deleteAppointment(ContactSchedule1,2);
printf("Création d'un nouveau contact\n");
t_contact_schedule* ContactSchedule2 = createContactSchedule();
printf("Création d'un nouveau contact\n");
t_contact_schedule* ContactSchedule3 = createContactSchedule();
t_schedule_cell *contact1 = createScheduleCell(2,ContactSchedule1);
t_schedule_cell *contact2 = createScheduleCell(2,ContactSchedule2);
t_schedule_cell *contact3 = createScheduleCell(2,ContactSchedule3);
t_schedule_list schedule = createScheduleList();
InsertCellOrderInScheduleList(schedule,contact1);
InsertCellOrderInScheduleList(schedule,contact2);
InsertCellOrderInScheduleList(schedule,contact3);
}