 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Titan
Joined: 11 Aug 2004 Posts: 5068 Location: imaginationland
|
Posted: Tue Jun 07, 2005 12:45 am Post subject: Re: performance hit? |
|
|
| Chris wrote: | | Quote: | | - the size of the include file of functions (or is this irrelevant/negligible in the overall scheme of things) | This will slightly increase the memory used by a script (probably by less than 100 KB). This is because each function along with its parameters and contents must be stored in memory, even if it is never called. | My scripts with a few function file includes (this one too) takes around 3k - for scripts and compiled exe's, should I expect something around 100k?!?  |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Tue Jun 07, 2005 2:24 am Post subject: |
|
|
I meant the amount of RAM the script uses. In this respect, functions are just like any other part of the script: the more of them there are, the more memory is needed.
Simple functions probably consume only around 1 KB each (1000 bytes), but it depends on how many parameters it accepts, what the function does, etc. |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5068 Location: imaginationland
|
Posted: Sun Sep 11, 2005 12:42 pm Post subject: |
|
|
| Updated. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Sun Sep 11, 2005 1:42 pm Post subject: |
|
|
Thanks for keeping this updated and for adding "in", "between", etc. It's a great benefit to the community.
(If anyone just started following this topic, the first post on the first page contains the updated functions). |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5068 Location: imaginationland
|
Posted: Fri Aug 04, 2006 4:15 pm Post subject: Re: performance hit? |
|
|
| Chris wrote: | | each function along with its parameters and contents must be stored in memory, even if it is never called. | Doesn't the semi-compilation process help at all? I thought that the memory addresses wouldn't even be created for functions/variables that aren't used. _________________
RegExReplace("irc.freenode.net/ahk", "^(?=(.(?=[\0-r\[]*((?<=\.).))))(?:[c-\x73]{2,8}(\S))+((2)|\b[^\2-]){2}\D++$", "$u3$1$3$4$2") |
|
| Back to top |
|
 |
Harmor
Joined: 06 Nov 2005 Posts: 183
|
Posted: Fri Aug 04, 2006 6:11 pm Post subject: |
|
|
Here are some that I use:
| Code: |
IsKeyReleased(a_szKeyName)
{
GetKeyState, state, %a_szKeyName%, P
If state = U
{
Return 1
}
Return 0
}
IsKeyPressed(a_szKeyName)
{
GetKeyState, state, %a_szKeyName%, P
If state = D
{
Return 1
}
Return 0
}
MouseEvent(a_xpos, a_ypos)
{
DllCall("mouse_event", uint,1, int,a_xpos, int,a_ypos, uint,0, int,0 )
}
IsProcessRunning(a_szName)
{
WinGet, szProcessName, ProcessName, A
if szProcessName = %a_szName%
{
return 1
}
return 0
}
|
_________________ //TODO: Create kewl sig... |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Sat Aug 05, 2006 2:29 pm Post subject: Re: performance hit? |
|
|
| Titan wrote: | | Chris wrote: | | each function along with its parameters and contents must be stored in memory, even if it is never called. | Doesn't the semi-compilation process help at all? I thought that the memory addresses wouldn't even be created for functions/variables that aren't used. | Functions are all stored in memory because it was originally planned that they could be called dynamically, such as %MyFunc%(). Since that feature is still planned, it's probably best to keep all functions in memory (since there would be no way to determine for certain that they're never called). |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 446
|
Posted: Tue Jan 01, 2008 3:06 am Post subject: |
|
|
It would be really helpful if these functions could somehow reside in the stdlib and be called without including them.
The only way I can think to do this, however, would be to create a separate file for every command, since there can't really be a prefix. Is there another way this can be accomplished? _________________ -Ben
SteamLab
SteamLab Wiki
[Broken] - My industrial music [on GarageBand] |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 5890
|
Posted: Tue Jan 01, 2008 3:26 am Post subject: |
|
|
| bmcclure wrote: | | Is there another way this can be accomplished? |
You may include the following in functions.ahk
| Code: | Functions_Init() { ; dummy function to initialise the library
} |
and you may call it once before you call any other function from the library, like:
| Code: | Functions_Init() ; call it once before any other function
MsgBox, % Random( 1,10 ) |
 |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 446
|
Posted: Tue Jan 01, 2008 3:41 am Post subject: |
|
|
Great idea, thanks!
At least it's a shorter and more generic command to remember than the path of the include... _________________ -Ben
SteamLab
SteamLab Wiki
[Broken] - My industrial music [on GarageBand] |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 5890
|
Posted: Tue Jan 01, 2008 3:44 am Post subject: |
|
|
| bmcclure wrote: | | Great idea |
It is .. but not mine. I read it in our forum.  |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5068 Location: imaginationland
|
Posted: Tue Jan 01, 2008 12:06 pm Post subject: |
|
|
Thanks for the heads up Skan. Version 1.5 final uploaded with StdLib compliant initialization function. _________________
RegExReplace("irc.freenode.net/ahk", "^(?=(.(?=[\0-r\[]*((?<=\.).))))(?:[c-\x73]{2,8}(\S))+((2)|\b[^\2-]){2}\D++$", "$u3$1$3$4$2") |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 446
|
Posted: Tue Jan 01, 2008 6:21 pm Post subject: |
|
|
I'm having some trouble passing the InputVar to StringReplace with this code since I re-downloaded.
Here is the function:
| Code: | StringReplace(ByRef InputVar, SearchText, ReplaceText = "", All = "") {
StringReplace, v, %InputVar%, %SearchText%, %ReplaceText%, %All%
Return, v
} |
But this puts the actual contents of the variable you pass to InputVar as the InputVar for StringReplace. Shouldn't it instead be like this?
| Code: | StringReplace(ByRef InputVar, SearchText, ReplaceText = "", All = "") {
StringReplace, v, InputVar, %SearchText%, %ReplaceText%, %All%
Return, v
} |
_________________ -Ben
SteamLab
SteamLab Wiki
[Broken] - My industrial music [on GarageBand] |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5068 Location: imaginationland
|
Posted: Tue Jan 01, 2008 6:27 pm Post subject: |
|
|
I actually snuck in an update a couple hours after my post which fixed the InputVar problem. _________________
RegExReplace("irc.freenode.net/ahk", "^(?=(.(?=[\0-r\[]*((?<=\.).))))(?:[c-\x73]{2,8}(\S))+((2)|\b[^\2-]){2}\D++$", "$u3$1$3$4$2") |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 446
|
Posted: Tue Jan 01, 2008 6:40 pm Post subject: |
|
|
Oh, I just downloaded the latest version right before posting that; I'll re-download again.
I also noticed this:
| Code: | IniRead(v, Filename, Section, Key, Default = "") {
IniRead, v, %Filename%, %Section%, %Key%, %Default%
Return, v
} |
Can't the first parameter be removed since it doesn't matter what was in the variable before and it's returned by the function?
I think it should be:
| Code: | IniRead(Filename, Section, Key, Default = "") {
IniRead, v, %Filename%, %Section%, %Key%, %Default%
Return, v
} |
_________________ -Ben
SteamLab
SteamLab Wiki
[Broken] - My industrial music [on GarageBand] |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|