Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Showing with 5648 additions and 2 deletions
File added
package p4a;
public class TableauPerso implements Structure{
private Object[] tableau;
private int nbElements;
public TableauPerso(int taille) {
if (taille < 0) {
throw new IllegalArgumentException("TableauPerso : taille negative " + taille);
}
this.tableau = new Object[taille];
nbElements = 0;
}
@Override
public void ajout(Object element, int position) {
if (position < 0 || position > nbElements) {
throw new IndexOutOfBoundsException("ajout : mauvais index " + position);
}
if (nbElements >= tableau.length) {
throw new IllegalStateException("ajout : tableau plein");
}
for (int i = nbElements; i > position; i--) {
tableau[i] = tableau[i - 1];
}
tableau[position] = element;
nbElements++;
}
@Override
public void suppression(int position) {
if (position < 0 || position >= nbElements) {
throw new IndexOutOfBoundsException("suppression : position incorrecte " + position);
}
for (int i = position + 1; i < nbElements; i++) {
tableau[i - 1] = tableau[i];
}
nbElements--;
}
@Override
public Object acces(int position) {
if (position > tableau.length || position < 0) {
throw new IllegalArgumentException("acces : position incorecte");
}
return tableau[position];
}
}
File added
package p4a;
public class TableauStd implements Structure {
private Object[] tableau;
public TableauStd(int taille) {
if (taille < 0) {
throw new IllegalArgumentException("TableauStd : taille negative " + taille);
}
this.tableau = new Object[taille];
}
@Override
public void ajout(Object element, int position) {
if (position > tableau.length) {
throw new UnsupportedOperationException("ajout : operation non supportee (taille depassee)");
}
else tableau[position] = element;
}
@Override
public void suppression(int position) {
throw new UnsupportedOperationException("suppression : operation non supportee");
}
@Override
public Object acces(int position) {
if (position > tableau.length || position < 0) {
throw new IllegalArgumentException("acces : position incorecte");
}
return tableau[position];
}
}
NbOperations,Version,CPU,Mem
100000,ArrayListStd,0.92,51480
100000,ArrayListStd,0.95,56940
100000,ArrayListStd,0.92,56776
100000,LinkedListStd,0.10,52112
100000,LinkedListStd,0.09,53852
100000,LinkedListStd,0.08,52200
125000,ArrayListStd,1.55,54820
125000,ArrayListStd,1.52,52968
125000,ArrayListStd,1.48,54828
125000,LinkedListStd,0.09,54064
125000,LinkedListStd,0.08,56140
125000,LinkedListStd,0.10,54168
150000,ArrayListStd,2.31,57088
150000,ArrayListStd,2.12,51980
150000,ArrayListStd,2.11,56308
150000,LinkedListStd,0.09,55792
150000,LinkedListStd,0.09,56036
150000,LinkedListStd,0.10,54148
175000,ArrayListStd,2.89,52024
175000,ArrayListStd,3.13,50152
175000,ArrayListStd,3.19,54896
175000,LinkedListStd,0.11,61116
175000,LinkedListStd,0.10,60140
175000,LinkedListStd,0.09,61112
200000,ArrayListStd,4.17,53848
200000,ArrayListStd,3.97,53180
200000,ArrayListStd,3.77,52120
200000,LinkedListStd,0.10,56440
200000,LinkedListStd,0.10,60040
200000,LinkedListStd,0.10,60172
225000,ArrayListStd,4.77,49972
225000,ArrayListStd,4.78,54088
225000,ArrayListStd,4.77,56096
225000,LinkedListStd,0.10,58104
225000,LinkedListStd,0.10,56340
225000,LinkedListStd,0.12,61356
250000,ArrayListStd,5.88,56984
250000,ArrayListStd,5.89,55976
250000,ArrayListStd,5.97,53852
250000,LinkedListStd,0.12,60876
250000,LinkedListStd,0.09,60288
250000,LinkedListStd,0.11,60244
275000,ArrayListStd,7.13,53848
275000,ArrayListStd,7.09,54256
275000,ArrayListStd,7.11,56284
275000,LinkedListStd,0.10,58288
275000,LinkedListStd,0.10,58044
275000,LinkedListStd,0.09,61472
300000,ArrayListStd,8.55,52108
300000,ArrayListStd,8.48,51784
300000,ArrayListStd,8.62,56328
300000,LinkedListStd,0.10,59400
300000,LinkedListStd,0.12,59320
300000,LinkedListStd,0.08,58440
#!/bin/bash
#Compare l'operation d'ajout en tete de liste sur les ArrayList et LinkedList standards
TESTS=3
STRUCT=2
NBOPERATIONS="100000 125000 150000 175000 200000 225000 250000 275000 300000"
echo "NbOperations,Version,CPU,Mem"
for nb in $NBOPERATIONS
do
for i in `seq $STRUCT`
do
for j in `seq $TESTS`
do
if [ $i = 1 ]
then
res=`(/usr/bin/time -f "%U,%M" java p4a.MainArrayListStdAddDebut $nb > /dev/null) 2>&1`
echo "$nb,ArrayListStd,$res"
else
res=`(/usr/bin/time -f "%U,%M" java p4a.MainLinkedListStdAddDebut $nb > /dev/null) 2>&1`
echo "$nb,LinkedListStd,$res"
fi
done
done
done
\ No newline at end of file
#!/bin/bash
STRUCT=3
NBOPERATIONS="25000 50000 75000 100000 250000 500000"
echo "Taille,Version,CPU,Mem"
for $nb in $NBOPERATIONS
do
for i in `seq $STRUCT`
do
if [ $i = 1 ]
then
res=`(/usr/bin/time -f "%U,%M" java p4a.MainArrayListStd $nb > /dev/null) 2>&1`
echo "$nb,ArrayListStd,$res"
elif [ $i = 2 ]
then
res=`(/usr/bin/time -f "%U,%M" java p4a.MainLinkedListStd $nb > /dev/null) 2>&1`
echo "$nb,LinkedListStd,$res"
else
res=`(/usr/bin/time -f "%U,%M" java p4a.MainArrayStd $nb > /dev/null) 2>&1`
echo "$nb,ArrayStd,$res"
fi
done
done
\ No newline at end of file
......@@ -4,15 +4,27 @@
## Problème
Description du Problème.
Description du Problème :
Description de tous les paramètres exploratoires du problème
Nous allons implémenter 3 opérations communes à différentes structures de données (tableaux, LinkedList et ArrayList) et comparer leurs performances avec leur implémentation standard.
Nous avons choisi d'utiliser le language objet java.
Proposition d'opérations :
- Ajout d'un élement à une certaine position (n'exite pas pour les tableaux standards, add() pour les LinkedList / ArrayList)
- Suppression d'un élement à une certaine position(n'existe pas pour les tableaux standards, remove() pour les LinkedList / ArrayList)
- Accès d'un élement à une certaine position(tab[position] pour les tableaux, get() pour les LinkedList / ArrayList)
## Dispositif expérimental
### Organisation objet
Description de l'organisation des classes et interfaces, ou diagramme de classes.
![](UML/diagramme.svg)
Toutes les structures de données vont implémenter une Interface *"Struture"* que nous allons créer et qui contiendra les opérations choisies.
Dans le package **Standard**, nous appelerons juste les bonnes méthodes déja présentes dans les libraires standards et dans
le package **Perso** nous réimplementerons par nous même ces opérations.
### Application
......
UML/diagramme.png

183 KiB

This diff is collapsed.
This diff is collapsed.
Compilation :
(dossier avec sources)
javac ./*.java
cd ..
java nomDossier.nomClasseMain
R
perf <- read.csv("perf.csv")
perf <- read.csv("perfAddStructDebut.csv")
library(ggplot2)
Comparaison LinkedList perso / standard :
CPU : ggplot(perf, aes(x=Taille,y=CPU, color=as.character(Version))) + geom_point() + geom_smooth(aes(group=Version)) + scale_color_discrete(name="Version") + ggtitle("Consommation CPU en fonction de la taille")
Mem : ggplot(perf, aes(x=Taille,y=Mem, color=as.character(Test))) + geom_point() + geom_smooth(aes(group=Test)) + scale_color_discrete(name="Test")
Comparaison LinkedListStd / ArrayListStd :
CPU : ggplot(perf, aes(x=NbOperations,y=CPU, color=as.character(Version))) + geom_point() + geom_smooth(aes(group=Version)) + scale_color_discrete(name="Version") + ggtitle("Consommation CPU pour ajout en tete de liste")
Mem : ggplot(perf, aes(x=NbOperations,y=Mem, color=as.character(Version))) + geom_point() + geom_smooth(aes(group=Version)) + scale_color_discrete(name="Version") + ggtitle("Consommation Memoire pour ajout en tete de liste") + expand_limits(y=0)
java ../P4A/src/main.MainArrayListStd 1500
\ No newline at end of file
graphiques/CPU_Linked_Array_List_Ajout_Debut_Liste.png

110 KiB

graphiques/LinkedListCPU.png

116 KiB

graphiques/Linked_Array_List_Ajout_Debut_Liste.png

260 KiB

graphiques/Mem_Linked_Array_List_Ajout_Debut_Liste.png

104 KiB