Skip to content
Snippets Groups Projects
Commit 5fabf318 authored by gossa's avatar gossa
Browse files

Initial commit en retard

parent ae8502bc
Branches
No related merge requests found
#!/bin/R
library(ggplot2)
df <- read.table("perf.dat", header=TRUE)
png("prealable.png")
ggplot(df,aes(x=taille,y=exectime,colour=version)) +
geom_point() + geom_smooth() +
ggtitle("Mesures préalables des 4 versions")
dev.off()
test taille version exectime mem
1 21800000 v4 0.45 86668
1 21800000 v2 0.56 86676
1 21800000 v1 2.30 86768
1 21800000 v3 2.14 86768
2 14057000 v4 0.31 56508
2 14057000 v2 0.36 56432
2 14057000 v3 1.45 56452
2 14057000 v1 1.54 56420
3 5089000 v4 0.10 21484
3 5089000 v2 0.13 21476
3 5089000 v3 0.52 21388
3 5089000 v1 0.53 21460
4 9411000 v4 0.20 38300
4 9411000 v2 0.22 38304
4 9411000 v3 0.94 38372
4 9411000 v1 0.98 38272
5 32386000 v4 0.71 128116
5 32386000 v2 0.80 128116
5 32386000 v3 3.28 128040
5 32386000 v1 3.46 128088
6 15352000 v4 0.34 61484
6 15352000 v2 0.39 61516
6 15352000 v3 1.62 61480
6 15352000 v1 1.64 61504
7 17015000 v4 0.37 68004
7 17015000 v2 0.42 68008
7 17015000 v3 1.72 67988
7 17015000 v1 1.79 68012
8 14627000 v4 0.31 58720
8 14627000 v2 0.37 58804
8 14627000 v3 1.57 58748
8 14627000 v1 1.62 58660
9 23156000 v4 0.49 91976
9 23156000 v2 0.59 92036
9 23156000 v3 2.44 92064
9 23156000 v1 2.45 92064
10 31361000 v2 0.77 124112
10 31361000 v4 0.68 124112
10 31361000 v3 3.19 124052
10 31361000 v1 3.32 124036
#!/bin/bash
echo -e "test\ttaille\tversion\texectime\tmem"
for test in `seq 1 10`
do
taille=${RANDOM}000
for version in 1 2 3 4
do
(
res=`(/usr/bin/time -f "%U\t%M" ./recherche $taille $version > /dev/null) 2>&1`
echo -e "$test\t$taille\tv$version\t$res"
) &
done
wait
done
prealable-mem.png

18.6 KiB

prealable.png

28.1 KiB

......@@ -30,53 +30,37 @@ void afficher_tableau(int *tableau, long long unsigned int n)
}
char rechercherV1(int *tableau, long long unsigned int n, int valeur)
long long int rechercher(int *tableau, long long unsigned int n, int valeur)
{
long long unsigned int i;
char trouve = 0;
long long int i;
long long int trouve = -1;
for (i=0; i<n; i++) {
if (tableau[i] == valeur) {
trouve=1;
trouve=i;
}
}
return trouve;
}
char rechercherV2(int *tableau, long long unsigned int n, int valeur)
{
long long unsigned int i;
char trouve = 0;
for (i=0; i<n; i++) {
if (tableau[i] == valeur) {
return 1;
}
}
return 0;
}
int main(int argc, char *argv[])
{
int *tableau;
int taille, valeur;
char trouve;
int version;
if (argc<2) {
printf("%s: opérande manquant\n",argv[0]);
printf("Recherche une valeur aléatoire dans un tableau d'entier aléatoire de taille n\n");
printf("Affiche le tableau et renvoie 1 si la valeur est trouvée, 0 sinon\n");
exit(1);
printf("Usage: %s taille version [graine]\n",argv[0]);
printf("Usage: %s taille [graine]\n",argv[0]);
}
unsigned int graine;
if (argc>3) {
graine = atoi(argv[3]);
if (argc>2) {
graine = atoi(argv[2]);
} else {
graine = time(NULL);
}
......@@ -84,26 +68,11 @@ int main(int argc, char *argv[])
srand(graine);
taille = strtoull(argv[1], (char **) NULL, 10);
version = strtoull(argv[2], (char **) NULL, 10);
valeur = rand()%MAX_VALEUR;
tableau = generer_tableau(taille);
switch(version) {
case 1:
afficher_tableau(tableau,taille);
trouve = rechercherV1(tableau, taille, valeur);
break;
case 2:
trouve = rechercherV1(tableau, taille, valeur);
break;
case 3:
afficher_tableau(tableau,taille);
trouve = rechercherV2(tableau, taille, valeur);
break;
case 4:
trouve = rechercherV2(tableau, taille, valeur);
break;
}
afficher_tableau(tableau,taille);
trouve = rechercher(tableau, taille, valeur);
printf("Valeur %d trouve: %d\n",valeur, trouve);
printf("Valeur %d trouvée: %d\n",valeur, trouve);
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment