Jump to content

Does constants and variables slow down script a lot?


Recommended Posts

Just wondering, how much does variables and constants eat memory and CPU, and also, does it have any other effects like slowing overall performance down?

The thing is that I want to include the whole periodic system into my run prompt script, so that you can make chemistry calculations by writing for example "M(Cl)" which equals 35.453.

The problem is that I'll need to declare 118 constants in my script, since i want a standalone au3 (and i think that reading from a file is slower)

So do you guys think that its going to be a big loss in performance or is AutoIt built so well that it doesn't really matter?

(The reason a am asking is that I don't want to create all the variables if I know its worthless)

[font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size]
Link to comment
Share on other sites

  • Developers

I do not think you will notice any difference when you define 118 constants, but why not simply use 1 array variable?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I do not think you will notice any difference when you define 118 constants, but why not simply use 1 array variable?

Jos

Well an array would be ok if the atom weights would be defined by atom number, but now i want to use the atom name, the function as it looks now is like this: (From ALIBI Run)

$NOReplacements = 5 ;The number of replacements to be done in the "_StringUseVars" Function, this must be same as in the $Replacements array
Dim $Replacements[$NOReplacements][2] = [["pi", '(3.14159265358979)'],["e", '(2.71828)'],["u", '(1.660539*10^-27)'],['NA', '(6.022142*10^23)'],[',', '.']]; the replacements to be done in the "_StringUseVars" Function

Func _StringUseVars($SUV_Start, $SUV_Amount = "", $SUV_ARRAY = "NONE")

    If $SUV_ARRAY <> "NONE" And IsArray($SUV_ARRAY) = 1 Then

        $SUV_MAINSTRING = $SUV_Start

        For $SUV_C = 0 To $SUV_Amount - 1 Step 1

            $SUV_C_T = $SUV_ARRAY[$SUV_C][0]
            $SUV_C_R = $SUV_ARRAY[$SUV_C][1]

            $SUV_MAINSTRING = StringReplace($SUV_MAINSTRING, $SUV_C_T, '' & $SUV_C_R & '')
        Next
        $SUV_RETURN = Execute($SUV_MAINSTRING)
        Dim $RETURN[2]
        $RETURN[0] = $SUV_MAINSTRING
        $RETURN[1] = $SUV_RETURN
        Return $RETURN

    EndIf
EndFunc   ;==>_StringUseVars

So i plan to implement it into that function (not by adding 118 more replacements though)

Edited by colafrysen
[font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size]
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...