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
Commits on Source (3)
File added
package P4a;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Random;
public class Main {
public static void main(String[] args) {
Collection<Integer> collection;
Random r = new Random();
r.setSeed(System.currentTimeMillis());
if (args.length < 4) {
System.exit(1);
}
//On récupère les paramètres (TypeDeStructure/Taille/Opération/TailleOp) :
String type = args[0];
int size = Integer.parseInt(args[1]);
String op = args[2];
int nbrOperation = Integer.parseInt(args[3]);
//Création de la structure choisie (ArrayList, LinkedList ou HashSet) :
switch (args[0]) {
default: {
collection = new ArrayList<Integer>();
break;
}
case "LinkedList": {
collection = new LinkedList<Integer>();
break;
}
case "Set": {
collection = new HashSet<Integer>();
}
}
//On remplie la structure de données aléatoires :
for (int i = 0; i < size; ++i) {
collection.add(r.nextInt());
}
//On effectue l'opération choisie (add, contains ou remove) :
switch (op) {
default: {
for (int i = 0; i < nbrOperation; ++i) {
collection.add(r.nextInt());
}
break;
}
case "contains": {
for (int i = 0; i < nbrOperation; ++i) {
collection.contains(r.nextInt());
}
break;
}
case "remove": {
for (int i = 0; i < nbrOperation; ++i) {
collection.remove(r.nextInt());
}
}
}
}
}
File added
image/perf.png

69.4 KiB

image/time_exec_add.png

138 KiB

image/time_exec_add_set.png

118 KiB

$ 2.20 112052
$ 2.04 107824
$ 2.01 113388
$ 2.05 114112
$ 1.99 108572
$ 1.94 109152
$ 1.91 115084
$ 1.94 113088
$ 2.03 114044
$ 2.04 116280
$ 1.98 110624
$ 2.04 114128
$ 2.05 111688
$ 1.97 109436
$ 2.11 111184
$ 2.14 112588
$ 2.00 114528
$ 1.89 110108
$ 2.02 108916
$ 2.02 111296
$ 2.01 111500
$ 2.11 115368
$ 2.00 110336
$ 1.95 110860
$ 2.08 112180
$ 2.17 113268
$ 2.05 108176
$ 2.17 110428
$ 2.09 111532
$ 2.08 115480
$ 2.06 114644
$ 2.09 112340
$ 2.15 111812
$ 2.03 114204
$ 1.99 112956
$ 2.03 106884
$ 2.05 108648
$ 2.03 112524
$ 2.02 116284
$ 2.17 115012
$ 2.17 112836
$ 2.11 109020
$ 1.98 110484
$ 1.88 110784
$ 1.94 110492
$ 1.90 113380
$ 1.85 107260
$ 1.88 109892
$ 1.78 112228
2.01 118220
2.00 110836
2.04 111808
1.89 108364
1.91 109688
1.89 113196
1.92 110072
1.96 114272
perf.png

69.4 KiB

#!/bin/bash
structType[0]="ArrayList"
structType[1]="LinkedList"
structType[2]="Set"
structSize[0]=1000
structSize[1]=25000
structSize[2]=50000
structSize[3]=75000
structSize[4]=100000
nbrOperation[0]=1000
nbrOperation[1]=25000
nbrOperation[2]=50000
nbrOperation[3]=75000
nbrOperation[4]=100000
operationType[0]="add"
operationType[1]="contains"
operationType[2]="remove"
echo -e "Size\tOperation\tNbrOperation\tType\tTime\tMem"
for size in ${structSize[*]}; do
for operation in ${operationType[*]}; do
for opSize in ${nbrOperation[*]}; do
for type in ${structType[*]}; do
res=$((/usr/bin/time -f "\t%U\t%M" java Main.java $type $size $operation $nbrOperation) 2>&1)
echo -e "$size\t$operation\t$nbrOperation\t$type\t$res"
done
done
done
done
echo "\n\nData saved in : perf.dat \n Launching the .R script...\n"
R --no-save < scriptPourPloter.R
echo "All execution are done !"
#!/bin/R
library(ggplot2) #a copier en premier après la commande "R" (juste R dan le terminal)
#Récupération des données :
perf <- read.table("perf.dat", header=TRUE) #deuxième commande
ggplot(perf,aes(x=NbrOperation, y=Time)) + geom_point() + facet_grid(Size~Operation)
ggsave("image/perf.png") #crée l'image
ggplot(perf,aes(x=NbrOperation, y=Time, colour=Size)) + geom_point() + geom_smooth() + facet_grid(Type~Operation)
ggsave("image/time_exec.png")
ggplot(subset(perf,Type=="Set"),aes(x=NbrOperation, y=Time, colour=Size)) + geom_point() + geom_smooth() + facet_grid(Type~Operation)
ggsave("image/time_exec_set.png")