Skip to content
Snippets Groups Projects
Commit b262a8a6 authored by Marchand Loïc's avatar Marchand Loïc
Browse files

Merge branch 'master' into 'master'

Master

See merge request !3
parents 10b0f565 0e2c0d80
Branches
1 merge request!3Master
File added
......@@ -4,8 +4,18 @@ import java.util.ArrayList;
public class RechercheL {
public static final String RESET = "\u001B[0m";
public static final String BLACK = "\u001B[30m";
public static final String RED = "\u001B[31m";
public static final String GREEN = "\u001B[32m";
public static final String YELLOW = "\u001B[33m";
public static final String BLUE = "\u001B[34m";
public static final String PURPLE = "\u001B[35m";
public static final String CYAN = "\u001B[36m";
public static final String WHITE = "\u001B[37m";
private static final int MAX_VALEUR = 150000;
private static Random randomGenerator;
private static Random randomGenerator = new Random();
public static ArrayList<Integer> genererListe(int taille) {
ArrayList<Integer> liste = new ArrayList<Integer>();
......@@ -15,19 +25,6 @@ public class RechercheL {
}
return liste;
}
public static boolean rechercherDansListe(ArrayList<Integer> liste, Integer cible) {
boolean b = false;
for (int value : liste) {
if (value == cible){
b = true;
return b;
}
else {
b = false;
}
}
return b;
}
public static void afficherListe(ArrayList<Integer> liste) {
for (int i=0; i<liste.size(); i++) {
......@@ -35,26 +32,50 @@ public class RechercheL {
}
}
public static void researchList(ArrayList<Integer> liste, Integer cible) {
if (liste.contains(cible) == true) {
System.out.println(GREEN + "Found !" + RESET);
}
else {
System.out.println(RED + "Not found ¡" + RESET);
}
}
public static void insertList(ArrayList<Integer> liste, Integer cible) {
int intMod = randomGenerator.nextInt(liste.size());
liste.add(1, cible);
liste.add(cible);
liste.add(intMod, cible);
liste.add(liste.size()-1, cible);
System.out.println(YELLOW + liste.get(cible) + RESET);
System.out.println(YELLOW + "Bien ajouté" + RESET);
}
public static void deleteList(ArrayList<Integer> liste, Integer cible) {
int intMod = randomGenerator.nextInt(liste.size());
System.out.println(GREEN + liste.size() + RESET);
liste.remove(1);
liste.remove(liste.indexOf(cible));
liste.remove(intMod);
liste.remove(liste.size()-1);
System.out.println(YELLOW + liste.size() + RESET);
}
public static void main(String[] argv){
if (argv.length < 2)
if (argv.length < 1)
{
System.out.println("Usage : java RechercheL [tailleListe] [cible]");
System.out.println("Usage : java RechercheL [tailleListe]");
System.exit(1);
}
int taille = Integer.parseInt(argv[0]);
randomGenerator = new Random(Integer.parseInt(argv[1]));
Integer cible = randomGenerator.nextInt(MAX_VALEUR);
Integer cible = randomGenerator.nextInt(taille);
System.out.println(CYAN + "Bonjour : Voici le résultat -v- " + RESET);
System.out.println("Bonjour : Voici le résultat -v- ");
ArrayList<Integer> a = genererListe(taille);
afficherListe(a);
boolean b = rechercherDansListe(a, cible);
if (b == true) {
System.out.println("Found !");
}
else {
System.out.println("Not found ¡");
}
//afficherListe(a);
researchList(a, cible);
insertList(a, cible);
deleteList(a, cible);
}
}
File deleted
rm perf.Rout
rm exectime.png
rm mem.png
101/exectime-sd.png

15.4 KiB

101/exectime.png

13.9 KiB

101/mem.png

13.4 KiB

......@@ -8,15 +8,15 @@ NB_TESTS2=5
echo -e "param\ttest\texectime\tmem"
RES=""
for test in `seq 1 $NB_TESTS`
for test in `seq 1 $NB_TESTS`
do
param=${RANDOM}000
for test2 in `seq 1 $NB_TESTS2`
do
do
(
RES="$param\t$test\t"
RES="$RES`(/usr/bin/time -f "%U\t%M" ./recherche $param > /dev/null) 2>&1`"
echo -e "$RES"
RES="$RES`(/usr/bin/time -f "%U\t%M" java RechercheL $param 20 > /dev/null) 2>&1`"
echo "$RES" >> perf_List.dat
) &
while [ `ps -A | grep -c recherche` -ge $NB_THREADS ]
......
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