AutoHotkey Community

It is currently May 26th, 2012, 1:56 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 42 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: performance hit?
PostPosted: June 7th, 2005, 12:45 am 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
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?!? :o


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 7th, 2005, 2:24 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 11th, 2005, 12:42 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
Updated.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 11th, 2005, 1:42 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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).


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: performance hit?
PostPosted: August 4th, 2006, 4:15 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
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.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 4th, 2006, 6:11 pm 
Offline

Joined: November 6th, 2005, 5:25 am
Posts: 182
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...


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: performance hit?
PostPosted: August 5th, 2006, 2:29 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 1st, 2008, 3:06 am 
Offline

Joined: November 24th, 2007, 9:07 pm
Posts: 774
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

My Trac projects
My Wiki
[Broken] - My music


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 1st, 2008, 3:26 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
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 )


:)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 1st, 2008, 3:41 am 
Offline

Joined: November 24th, 2007, 9:07 pm
Posts: 774
Great idea, thanks!

At least it's a shorter and more generic command to remember than the path of the include...

_________________
Ben

My Trac projects
My Wiki
[Broken] - My music


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 1st, 2008, 3:44 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
bmcclure wrote:
Great idea


It is .. but not mine. I read it in our forum. :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 1st, 2008, 12:06 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
Thanks for the heads up Skan. Version 1.5 final uploaded with StdLib compliant initialization function.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 1st, 2008, 6:21 pm 
Offline

Joined: November 24th, 2007, 9:07 pm
Posts: 774
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

My Trac projects
My Wiki
[Broken] - My music


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 1st, 2008, 6:27 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
I actually snuck in an update a couple hours after my post which fixed the InputVar problem.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 1st, 2008, 6:40 pm 
Offline

Joined: November 24th, 2007, 9:07 pm
Posts: 774
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

My Trac projects
My Wiki
[Broken] - My music


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 42 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Exabot [Bot] and 18 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group