Jump to content

Optimizing AutoIt v3 Code


 Share

Recommended Posts

Hi everyone,

I'm writing to ask you guys how to Optimize a Programme? I am sorry if any of you guys find my questions ridiculous. It just happens that, when I, and some of other people code some programme to achieve the same goal. My programme often consume like 1.5 times the memory, compared to the other one; and of course, my programme does not run as effectively as the other one. Moreover, I have looked for some Optimizing Books for the last week, but I couldn't find any. So, can someone recommend me a book, or some article to read about it? Are there any rules that one should remember when coding?

I do know some basic rules like:

  • When performing a nesting If Statements, one should check for the one that is not likely to happen first (or in other words, the first statement is the one that often returns False).
  • Use $s += 1 instead of $s = $s + 1.
  • Doing maths in intergers is much more quichly than doing maths in reals.

But those rules are applied in C, do they still hold in AutoIt?

And by the way, is there anyway to free the dummy variable's usage?

As far as I notice, when I just open my programme, say, the memory it uses is 3,500Kb. And after like one or two hours, it reduces to 1,500Kb. So, it appears that my programme is wasting like 2,000Kb on dummy variable, or something along the line. Is there any way to tell my computer to trash those Usage?

Thanks a lot in advance,

And have a nice day, :D

Link to comment
Share on other sites

Wasn't there something written by Gary that releases the unused memory at start up of app? I'll go looking.

#96101

Keep in mind this was awhile ago, so it may not work correctly. Also does 1 meg of memory really make a whole hell of a lot of differnece in windows activities?

Edited by beerman
Link to comment
Share on other sites

whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

Thanks a lot for all of your responds. :D

Wasn't there something written by Gary that releases the unused memory at start up of app? I'll go looking.

#96101

Keep in mind this was awhile ago, so it may not work correctly. Also does 1 meg of memory really make a whole hell of a lot of differnece in windows activities?

Yup, it's still working perfectly. Thanks a lot. :

The most important is the language u write your program in

If u want performance C would be a good choice.

Many games are written in C.

I don't reaaly know, but I find C's syntax(es ?) a little bit complicated to remember.. :-ss

Yes He is.

I got locked into the wrong mode, and the nested part only hit home after posting and rereading the original message.

Should hold true for AutoIt. But only counts for a small speed gain.

Same trick can be applied for array calls. Replacing the array[element] call with a normal variable for use inside inner loops. (when applicable)

Err, I'm not sure if I fully understand this part. Do you mean that when working with $a0, $a1, $a2, $a3 is faster than working with $a[0], $a[1], $a[2], and $a[3]?

But moving whatever process from inside a inner loop to the outside of it will generally result in the biggest speed gain. (90% seems to be the general value here.)

Like

$a[0] = 1

$a[1] = 1

$a[2] = 1

is 10% (or is it 90%?) faster than:

For $s = 0 To 2

$a = 1

Next

Thanks guys agian, :huggles:

Edited by eEniquEe
Link to comment
Share on other sites

whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

Yes, but of course not for a array element that is being actively scanned. Well It could be, but thats just silly coding. :huggles:

So like.

Local $B_local = $aB_Array[1][2][3]
For $iLongInnerLoop = 1 to $iPlenty
    $aA_Array[$iLongInnerLoop] = $iValue * $iSetting * $B_local
Next
instead of,
For $iLongInnerLoop = 1 to $iPlenty
    $aA_Array[$iLongInnerLoop] = $iValue * $iSetting * $aB_Array[1][2][3]
Next

The 90% is related to the maximum speed gain you can achieve between a not yet optimized version and a maxed optimized version. In that 90% of that gains is most likely achieved by inner loop adjustments.

So

Local $y
For $i1 = 0 to 100
    $Y = $i1 * $iSomeSetting
    For $i2 = 0 to 100
        SomeFunction($Y, $i2)
    Next
Next
instead of
For $i1 = 0 to 100
    For $i2 = 0 to 100
        SomeFunction($i1 * $iSomeSetting, $i2)
    Next
Next

Well, yah, I think I get it now. Thanks all for your great help. I'll try to mess with those ideas a bit, to see if they work. :D
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...