Page 1 of 4

programme trop lent

Unread postPosted: 10 Feb 2012, 22:25
by hermes
bonjour,

j'ai un problème je viens de faire un programme mais sont exécution qui se passe bien demande environ 30 s. Sachant que se programme est appeler plusieurs fois au sein d'autres.
j'ai essayer de programmé en C mais je n'est pas réussis pensez-vous qu'une voyage 200 ou une autre soit la solution?

Hermès

Re: programme trop lent

Unread postPosted: 10 Feb 2012, 22:35
by critor
Non. La Voyage 200 est même un peu plus lente que la TI-89 Titanium.

Au-dessus, on passe directement aux Nspire.

De quel type de programme s'agit-il?

Re: programme trop lent

Unread postPosted: 11 Feb 2012, 12:40
by Lionel Debroux
En effet, poste-nous ton programme :)

L'utilisation du C, et de primitives de plus bas niveau, permet parfois de réduire la complexité algorithmique du calcul, et ainsi d'obtenir des gains de temps très appréciables.

Re: programme trop lent

Unread postPosted: 11 Feb 2012, 15:34
by hermes
bonjour,

voilà mon programme il a pour fonction de calculer toutes les caractéristiques de l'aire sur un diagramme d'air humide pour plus information aller voir le site dimclim.fr.

Code: Select all
()
Prgm
Local ch1,ch2
Define aero\calc1()=Prgm
DelVar x
If string(v)="x"
"v"»str
If string(r)="x"
"r"»str
If string(t)="t" Then
"t"»str
x»t
EndIf
expÐlist(solve(v=(287t*(0.621+r))/(0.621p),x),x)»x
x[1]»#str
EndPrgm

Define aero\calc2()=Prgm
DelVar x
If string(h)="x"
"h"»str
If string(r)="x"
"r"»str
If string(ˆ)="x"
"ˆ"»str
expÐlist(solve(h=1.006ˆ+r*(2501+1.83ˆ),x),x)»x
x[1]»#str
EndPrgm

Define aero\calc3()=Prgm
DelVar x
If string(‘)="x"
"‘"»str
If string(r)="x"
"r"»str
If string(t)="t" Then
"t"»str
x»t
EndIf
expÐlist(solve(r=((0.624‘)/100*—^(13.7-5120/t))/(1-‘/100*—^(13.7-5120/t)),x),x)»x
x[1]»#str
EndPrgm

Define aero\calc4()=Prgm
DelVar x
If string(t)="t" Then
"t"»str
x»t
Else
"ˆ"»str
EndIf
expÐlist(solve(t=ˆ+273.15,x),x)»x
x[1]»#str
DelVar x
EndPrgm
¨DelVar t,ˆ,‘,r,h,v,p,o
setMode("Exact/Approx","APPROXIMATE")
ClrIO
Request "ptot=101325 Pa o/n",ch0
If string(ch0)"n" Then
101325»p
Else
Input "ptot",p
EndIf
If string(ˆ)="ˆ" and string(h)="h" and string(r)="r" and string(‘)="‘" Then
PopUp {"ˆ","h","Vm","r","‘"},ch1
PopUp {"ˆ","h","Vm","r","‘"},ch2
If ch1=1 or ch2=1
Input "Temperature ˆ _¬C",ˆ
If ch1=2 or ch2=2
Input "Entalpie H _kj/kgas",h
If ch1=3 or ch2=3
Input "Volume massique Vm _m¯/kg",v
If ch1=4 or ch2=4
Input "Humidite absolut _kge/kgas",r
If ch1=5 or ch2=5
Input "Hydrometrie _%",‘
EndIf
If string(ˆ)="ˆ"
x»ˆ
If string(h)="h"
x»h
If string(v)="v"
x»v
If string(r)="r"
x»r
If string(‘)="‘"
x»‘
If string(ˆ)"x" and (string(h)"x" xor string(r)"x") Then
aero\calc4()
aero\calc2()
aero\calc3()
aero\calc1()
Goto fin
EndIf
If string(ˆ)"x" and string(v)"x" Then
aero\calc4()
aero\calc1()
aero\calc2()
aero\calc3()
Goto fin
EndIf
If string(ˆ)"x" and string(‘)"x" Then
aero\calc4()
aero\calc3()
aero\calc2()
aero\calc1()
Goto fin
EndIf


If string(h)"x" and string(v)"x" Then
x»ˆ
"ˆ"»strˆ
y»r
"r"»strr
expÐlist(solve(v=(287t*(0.621+r))/(0.621p) and h=1.006ˆ+r*(2501+1.83ˆ),{x,y}),{x,y})»listsol
listsol[1,1]»#strˆ
listsol[1,2]»#strr
aero\calc4()
aero\calc3()
Goto fin
EndIf
If string(h)"x" and string(r)"x" Then
aero\calc2()
aero\calc4()
aero\calc3()
aero\calc1()
Goto fin
EndIf
If string(‘)"x" and string(h)"x" Then
expÐlist(solve(v=(287t*(0.621+r))/(0.621p) and h=1.006ˆ+r*(2501+1.83ˆ) and r=((0.624‘)/100*—^(13.7-5120/t))/(1-‘/100*—^(13.7-5210/t)) and t=ˆ+273.15,{ˆ,r,v,t}),{ˆ,r,v,t})»listsol
listsol[1,1]»ˆ
listsol[1,2]»r
listsol[1,3]»v
Goto fin
EndIf


If string(v)"x" and string(r)"x" Then
aero\calc1()
aero\calc4()
aero\calc2()
aero\calc3()
Goto fin
EndIf
If string(‘)"x" and string(v)"x" Then
"t"»strt
y»r
"r"»strr
expÐlist(solve(v=(287t*(0.621+r))/(0.621p) and r=((0.624‘)/100*—^(13.7-5120/(ˆ+273.15)))/(1-‘/100*—^(13.7-5120/(ˆ+273.15))),{t,z}),{t,z})»listsol
listsol[1,1]»#strt
listsol[1,2]»#strr
aero\calc4()
aero\calc2()
Goto fin
EndIf


If string(r)"x" and string(‘)"x" Then
aero\calc3()
aero\calc1()
aero\calc4()
aero\calc2()
EndIf
Lbl fin
5120/(ln((r+0.62099999999998)/r)+13.7)-273.15»ˆr
DelVar x
nSolve((h-x)/(2490+1.96x)=(0.621*100*—^(13.7-5120/(x+273.15))*101325)/(100*101325-100*—^(13.7-5120/(x+273.15))*101325),x)»ˆh

ClrIO
Output 0,0,"ˆ:"
Output 0,10,ˆ
Output 10,0,"h:"
Output 10,10,h
Output 20,0,"r:"
Output 20,10,r
Output 30,0,"‘:"
Output 30,10,‘
Output 40,0,"Vm:"
Output 40,18,v
Output 50,0,"ˆr:"
Output 50,18,ˆr
Output 60,0,"ˆh:"
Output 60,18,ˆh
ˆ»air[1]
h»air[2]
r»air[3]
‘»air[4]
v»air[5]
ˆr»air[6]
Pause
EndPrgm

Re: programme trop lent

Unread postPosted: 11 Feb 2012, 18:33
by Lionel Debroux
Hmm. Ca fait longtemps que je n'ai pas fait de TI-BASIC, mais là, la seule cause de lenteur que je vois est l'utilisation des fonctions de la famille solve()... auquel cas il n'y a pas grand chose à faire.
D'autres avis ?

Re: programme trop lent

Unread postPosted: 12 Feb 2012, 12:12
by Bisam
J'ai l'impression que beaucoup de calculs et d'affectations sont faits en double, voire plus.
Il faudrait chercher à optimiser l'algorithme...

Peux-tu fournir le fichier du programme (zippé) dans la discussion pour que je puisse y jeter un coup d'oeil sans les fautes de traduction de caractères ?

Re: programme trop lent

Unread postPosted: 12 Feb 2012, 14:17
by hermes
bonjour,

bien sur voila une copie zipé

Hermè
aero.airhumid.zip

Re: programme trop lent

Unread postPosted: 12 Feb 2012, 15:48
by Loulou 54
Attention si tu as archivé ton programme avant de l'avoir exécuté une fois, il va être tokénisé à chaque lancement, ce qui prend un temps non négligeable si le programme est un peu long !
Essaye de désarchiver tous les programmes et sous programmes qui interviennent puis de tous les exécuter une fois. Ensuite tu pourras les archiver à nouveau si tu veux. :)

Re: programme trop lent

Unread postPosted: 12 Feb 2012, 16:24
by hermes
j'ai archivé mon programme uniquement pour le mettre en ligne

Hermès

Re: programme trop lent

Unread postPosted: 12 Feb 2012, 17:56
by Bisam
Je regarderai ce soir. Pour l'instant, je ne suis pas chez moi... et je n'ai pas mon câble, ni d'émulateur.