Pages : 1
#1 Le 11/05/2016, à 16:47
- msg21
Pas assez de mémoire ?
Bonjour,
N'ayant que 1 gigat de mémoire vive (Ram), ce code en python prend 6 minutes lors de son exécution.Si vous avez beaucoup plus de mémoire , voudriez vous le tester pour que je sache s'il fera moins de temps.
Par ailleurs, comment améliorer le temps de l'exécution de ce code. car il consomme plus de mémoire
Merci d'avance
Dernière modification par msg21 (Le 17/09/2016, à 08:22)
Hors ligne
#2 Le 11/05/2016, à 17:12
- claudius01
Re : Pas assez de mémoire ?
Bonjour,
msg21, cela me dit quelque chose ;-))
Ne serait-ce pas la suite ou un doublon de RESOLU ET PUBLIE Test d'un code python (SVP)
Hors ligne
#3 Le 11/05/2016, à 17:54
- msg21
Re : Pas assez de mémoire ?
Bonjour claudius
Tout a fait. J ai donné une amélioration , le code va un peu plus vite mais je cherche un astuce pour qu il consomme pas trop de mémoire
Hors ligne
#4 Le 11/05/2016, à 18:36
- claudius01
Re : Pas assez de mémoire ?
Chose faite sur un CentOS 7.0 - 2 GBytes
-----------------------------------------------------
[claudius@CentOS-7 msg21]$ time python test1.py
number of cities=
(0, 'Time:', 0.0006401538848876953)
The program is looking for the Hamiltonien cycles...
(1, 'Time:', 0.0006880760192871094)
The program is looking for the Hamiltonien cycles...
(2, 'Time:', 0.0008611679077148438)
The program is looking for the Hamiltonien cycles...
(3, 'Time:', 0.001049041748046875)
The program is looking for the Hamiltonien cycles...
(4, 'Time:', 0.0017211437225341797)
The program is looking for the Hamiltonien cycles...
(5, 'Time:', 0.0027701854705810547)
The program is looking for the Hamiltonien cycles...
(6, 'Time:', 0.0055010318756103516)
The program is looking for the Hamiltonien cycles...
(7, 'Time:', 0.01064610481262207)
The program is looking for the Hamiltonien cycles...
(8, 'Time:', 0.020989179611206055)
The program is looking for the Hamiltonien cycles...
(9, 'Time:', 0.04163718223571777)
The program is looking for the Hamiltonien cycles...
(10, 'Time:', 0.08366107940673828)
The program is looking for the Hamiltonien cycles...
(11, 'Time:', 0.16598916053771973)
The program is looking for the Hamiltonien cycles...
(12, 'Time:', 0.3309650421142578)
The program is looking for the Hamiltonien cycles...
(13, 'Time:', 0.6724181175231934)
The program is looking for the Hamiltonien cycles...
(14, 'Time:', 1.3934299945831299)
The program is looking for the Hamiltonien cycles...
(15, 'Time:', 2.8240129947662354)
The program is looking for the Hamiltonien cycles...
(16, 'Time:', 5.862574100494385)
The program is looking for the Hamiltonien cycles...
(17, 'Time:', 11.961552143096924)
The program is looking for the Hamiltonien cycles...
(18, 'Time:', 24.185943126678467)
The program is looking for the Hamiltonien cycles...
(19, 'Time:', 48.99826502799988)
The program is looking for the Hamiltonien cycles...
(20, 'Time:', 98.29603719711304)
The program is looking for the Hamiltonien cycles...
('Time:', 98.55295014381409)
end
real 1m41.966s
user 1m40.292s
sys 0m1.393s
75% de la mémoire occupée à la dernière itération et 0% de swap ;-)
Dernière modification par claudius01 (Le 11/05/2016, à 18:37)
Hors ligne
#5 Le 11/05/2016, à 20:53
- alius
Re : Pas assez de mémoire ?
Salut
voilà de mon coté ce que ça donne :
un peu plus de 1GO de ram consomée
output :
number of cities=
(0, 'Time:', 0.0004849433898925781)
The program is looking for the Hamiltonien cycles...
(1, 'Time:', 0.0006000995635986328)
The program is looking for the Hamiltonien cycles...
(2, 'Time:', 0.0008111000061035156)
The program is looking for the Hamiltonien cycles...
(3, 'Time:', 0.0011811256408691406)
The program is looking for the Hamiltonien cycles...
(4, 'Time:', 0.0018880367279052734)
The program is looking for the Hamiltonien cycles...
(5, 'Time:', 0.0033690929412841797)
The program is looking for the Hamiltonien cycles...
(6, 'Time:', 0.005956172943115234)
The program is looking for the Hamiltonien cycles...
(7, 'Time:', 0.011080026626586914)
The program is looking for the Hamiltonien cycles...
(8, 'Time:', 0.021258115768432617)
The program is looking for the Hamiltonien cycles...
(9, 'Time:', 0.04204511642456055)
The program is looking for the Hamiltonien cycles...
(10, 'Time:', 0.08457016944885254)
The program is looking for the Hamiltonien cycles...
(11, 'Time:', 0.16745901107788086)
The program is looking for the Hamiltonien cycles...
(12, 'Time:', 0.33180713653564453)
The program is looking for the Hamiltonien cycles...
(13, 'Time:', 0.6094081401824951)
The program is looking for the Hamiltonien cycles...
(14, 'Time:', 0.9837150573730469)
The program is looking for the Hamiltonien cycles...
(15, 'Time:', 1.741698980331421)
The program is looking for the Hamiltonien cycles...
(16, 'Time:', 3.315830945968628)
The program is looking for the Hamiltonien cycles...
(17, 'Time:', 6.5546979904174805)
The program is looking for the Hamiltonien cycles...
(18, 'Time:', 13.044219017028809)
The program is looking for the Hamiltonien cycles...
(19, 'Time:', 25.9138400554657)
The program is looking for the Hamiltonien cycles...
(20, 'Time:', 51.66533803939819)
The program is looking for the Hamiltonien cycles...
('Time:', 51.90980505943298)
end
Alius
Hors ligne
#6 Le 11/05/2016, à 21:19
- msg21
Re : Pas assez de mémoire ?
Merci à vous claudius et alius.
C'est nettement meilleur le temps qu'ont fait vos PC par rapport à mon ordinateur (6 minutes).
Hors ligne
#7 Le 12/05/2016, à 10:59
- msg21
Re : Pas assez de mémoire ?
Bonjour,
J'ai commenté un break, merci infiniment de me dire combien ça prend du temps cette fois.
Hors ligne
#8 Le 12/05/2016, à 21:44
- claudius01
Re : Pas assez de mémoire ?
Bonsoir,
???, sauf erreur de ma part, je ne vois dans le programme qu'un break déjà commenté; à savoir:
...
print("Time:", time.time() - start)
#break #break if we want only one cycle
...
Question: Faut-il le "décommenter" ?
Dernière modification par claudius01 (Le 12/05/2016, à 21:46)
Hors ligne
#9 Le 13/05/2016, à 07:10
- msg21
Re : Pas assez de mémoire ?
Bonsoir,
???, sauf erreur de ma part, je ne vois dans le programme qu'un break déjà commenté; à savoir:
... print("Time:", time.time() - start) #break #break if we want only one cycle ...
Question: Faut-il le "décommenter" ?
Merci pour votre réponse,
Il ne faut pas la décommenter, elle doit rester comme ceci #break #break if we want only one cycle (autrement dit comme si la ligne est supprimée)
Dernière modification par msg21 (Le 13/05/2016, à 08:22)
Hors ligne
#10 Le 13/05/2016, à 09:17
- claudius01
Re : Pas assez de mémoire ?
Bonjour,
Oups, j'avais pas vu la réédition de ton 1st post ;-)
Sinon, j'ai dû arrêter à 90% de RAM occupée sur les 2 GBytes configurées
[claudius@CentOS-7 msg21]$ time python test2.py
number of cities=
(0, 'Time:', 0.0009260177612304688)
The program is looking for the Hamiltonien cycles...
(1, 'Time:', 0.0010600090026855469)
The program is looking for the Hamiltonien cycles...
(2, 'Time:', 0.0012359619140625)
The program is looking for the Hamiltonien cycles...
(3, 'Time:', 0.001528024673461914)
The program is looking for the Hamiltonien cycles...
(4, 'Time:', 0.0030219554901123047)
The program is looking for the Hamiltonien cycles...
(5, 'Time:', 0.00427699089050293)
The program is looking for the Hamiltonien cycles...
(6, 'Time:', 0.006422996520996094)
The program is looking for the Hamiltonien cycles...
(7, 'Time:', 0.011628866195678711)
The program is looking for the Hamiltonien cycles...
(8, 'Time:', 0.020798921585083008)
The program is looking for the Hamiltonien cycles...
(9, 'Time:', 0.04274296760559082)
The program is looking for the Hamiltonien cycles...
(10, 'Time:', 0.08706092834472656)
The program is looking for the Hamiltonien cycles...
(11, 'Time:', 0.16997599601745605)
The program is looking for the Hamiltonien cycles...
(12, 'Time:', 0.33658504486083984)
The program is looking for the Hamiltonien cycles...
(13, 'Time:', 0.6668870449066162)
The program is looking for the Hamiltonien cycles...
(14, 'Time:', 1.35211181640625)
The program is looking for the Hamiltonien cycles...
(15, 'Time:', 2.733891010284424)
The program is looking for the Hamiltonien cycles...
(16, 'Time:', 5.589372873306274)
The program is looking for the Hamiltonien cycles...
(17, 'Time:', 11.512418985366821)
The program is looking for the Hamiltonien cycles...
(18, 'Time:', 23.469934940338135)
The program is looking for the Hamiltonien cycles...
(19, 'Time:', 47.485546827316284)
The program is looking for the Hamiltonien cycles...
(20, 'Time:', 95.51285290718079)
The program is looking for the Hamiltonien cycles...
('Time:', 95.77054500579834)
(21, 'Time:', 95.7706139087677)
The program is looking for the Hamiltonien cycles...
^C
Traceback (most recent call last):
File "test2.py", line 115, in <module>
if T[0]<=0 or (j in R(T) and j!=0):
File "test2.py", line 31, in R
U.append(T[i+1])
KeyboardInterrupt
real 2m6.098s
user 2m3.986s
sys 0m1.813s
Hors ligne
#11 Le 13/05/2016, à 09:31
- msg21
Re : Pas assez de mémoire ?
Ok
merci claudius.
Hors ligne
#12 Le 13/05/2016, à 12:44
- GP974
Re : Pas assez de mémoire ?
Sur une arch avec 12go de ram
Fini a 90% mem
time python2 lourdalgo.py
number of cities=
(0, 'Time:', 0.00025010108947753906)
The program is looking for the Hamiltonien cycles...
(1, 'Time:', 0.0002720355987548828)
The program is looking for the Hamiltonien cycles...
(2, 'Time:', 0.00040411949157714844)
The program is looking for the Hamiltonien cycles...
(3, 'Time:', 0.0006401538848876953)
The program is looking for the Hamiltonien cycles...
(4, 'Time:', 0.00115203857421875)
The program is looking for the Hamiltonien cycles...
(5, 'Time:', 0.002067089080810547)
The program is looking for the Hamiltonien cycles...
(6, 'Time:', 0.003951072692871094)
The program is looking for the Hamiltonien cycles...
(7, 'Time:', 0.007623195648193359)
The program is looking for the Hamiltonien cycles...
(8, 'Time:', 0.016937971115112305)
The program is looking for the Hamiltonien cycles...
(9, 'Time:', 0.03983712196350098)
The program is looking for the Hamiltonien cycles...
(10, 'Time:', 0.08006811141967773)
The program is looking for the Hamiltonien cycles...
(11, 'Time:', 0.1458911895751953)
The program is looking for the Hamiltonien cycles...
(12, 'Time:', 0.3162209987640381)
The program is looking for the Hamiltonien cycles...
(13, 'Time:', 0.6745090484619141)
The program is looking for the Hamiltonien cycles...
(14, 'Time:', 1.2280950546264648)
The program is looking for the Hamiltonien cycles...
(15, 'Time:', 2.323683977127075)
The program is looking for the Hamiltonien cycles...
(16, 'Time:', 4.460281133651733)
The program is looking for the Hamiltonien cycles...
(17, 'Time:', 8.798917055130005)
The program is looking for the Hamiltonien cycles...
(18, 'Time:', 17.447412967681885)
The program is looking for the Hamiltonien cycles...
(19, 'Time:', 34.85766315460205)
The program is looking for the Hamiltonien cycles...
(20, 'Time:', 69.58714199066162)
The program is looking for the Hamiltonien cycles...
('Time:', 69.80510306358337)
(21, 'Time:', 69.80513501167297)
The program is looking for the Hamiltonien cycles...
('Time:', 107.556321144104)
(22, 'Time:', 107.55635118484497)
The program is looking for the Hamiltonien cycles...
('Time:', 159.73477697372437)
(23, 'Time:', 159.73480796813965)
The program is looking for the Hamiltonien cycles...
('Time:', 237.7790710926056)
(24, 'Time:', 237.77910208702087)
The program is looking for the Hamiltonien cycles...
('Time:', 357.88212418556213)
(25, 'Time:', 357.8821551799774)
The program is looking for the Hamiltonien cycles...
('Time:', 534.1812310218811)
(26, 'Time:', 534.1812591552734)
The program is looking for the Hamiltonien cycles...
^CTraceback (most recent call last):
File "lourdalgo.py", line 119, in <module>
d[j]+=[F(j,T)]
KeyboardInterrupt
^C
real 12m7.270s
user 12m3.403s
sys 0m3.413s
Hors ligne
Pages : 1