Jump to content

Script using too much cpu


Rex
 Share

Recommended Posts

Hi i have crated a simpel script to keep track of a window.

The script is running on/thru a citrix server, but it uses to many resurces ~8 mb ram and 1-2 % cpu.

Can any of u help me so the script dont uses so much.

$Count = 0
While 1
_check()
Sleep(100)
WEnd

Func _check()
    If WinActive("Navision XAL", "Udskriftsmuligheder") then
    $Count = $Count + 1
    ;GUICtrlSetData($counter, $Count)
    Sleep(1000)
    WinWaitNotActive("Navision XAL", "Udskriftsmuligheder")
    EndIf
If $count = 37 Then
    MsgBox(16, "Warning", "Om ca. 2 følgeseddler kommer følgeseddels fejlen") ;
    $Count = 0
    
EndIf
EndFunc

/Rex

Link to comment
Share on other sites

Hi,

To reduce CPU usage, you can increase the sleep delay.

$Count = 0

While 1

_check()

Sleep(100)

WEnd

I dont know if you need to have exactly 100 ms of sleep but if not you should increase it

and choose a value that fit your needs (by testing for instance with 200,300,...,800, etc ).

Iklim

Link to comment
Share on other sites

Hello Rex,

Would it be correct assume that the memory usage is more problematic for your environment than CPU usage?

How are you running the script?

When I run the script "compiled" on my old laptop, the memory usage is @ 3,784 K with CPU usage of 1-2%.

Running it from the "Run Script" link in Start->Programs, the memory usage is @ 6,924 K with CPU usage of 1-2%.

Zach...

Link to comment
Share on other sites

Hello Rex,

Would it be correct assume that the memory usage is more problematic for your environment than CPU usage?

How are you running the script?

When I run the script "compiled" on my old laptop, the memory usage is @ 3,784 K with CPU usage of 1-2%.

Running it from the "Run Script" link in Start->Programs, the memory usage is @ 6,924 K with CPU usage of 1-2%.

Zach...

My script is compiled, and to be true then i'm not sure if it's the cpu usage or the mem usage that's the prob.

becurce the script is running on a citrix server, all i know is that when i start the script the sys works slower :P

But hey maby it's not my script alt all, maby it's system thats slow ???

I have to come back on that.

but thx for responding

/Rex

Link to comment
Share on other sites

Hi,

To reduce CPU usage, you can increase the sleep delay.

$Count = 0

While 1

_check()

Sleep(100)

WEnd

I dont know if you need to have exactly 100 ms of sleep but if not you should increase it

and choose a value that fit your needs (by testing for instance with 200,300,...,800, etc ).

Hmm that i could try

/Rex

Link to comment
Share on other sites

you can also try some different compile option.

The Aut2Exe.exe program can be run from the command line as follows:

Aut2exe.exe /in <infile.au3> [/out <outfile.exe>] [/icon <iconfile.ico>] [/nodecompile] [/comp 0-4] [/pass <passphrase>] [/nopack] [/ansi] [/unicode]

like playing with /comp, /nodecompile and /nopack.

Iklim

Link to comment
Share on other sites

What you may want to try is taking out your Sleep commands and replacing the first one with the GUIGetMsg() function. This gives other applications a chance to use processing time. (Check out the REMARKS section of this command).

While 1
_check()
GUIGetMsg()
WEnd

Func _check()
    If WinActive("Navision XAL", "Udskriftsmuligheder") then
    $Count = $Count + 1
    ;GUICtrlSetData($counter, $Count)
    WinWaitNotActive("Navision XAL", "Udskriftsmuligheder")
    EndIf
If $count = 37 Then
    MsgBox(16, "Warning", "Om ca. 2 følgeseddler kommer følgeseddels fejlen") ;
    $Count = 0
   
EndIf
EndFunc

Hope this is helpful. Cheers!

"Intelligence is the ability to adapt to change."                                      - Stephen Hawking                                        "...not the ability to exploit others."                                                  - OldCoder
Link to comment
Share on other sites

  • 1 month later...

What you may want to try is taking out your Sleep commands and replacing the first one with the GUIGetMsg() function. This gives other applications a chance to use processing time. (Check out the REMARKS section of this command).

While 1
_check()
GUIGetMsg()
WEnd

Func _check()
    If WinActive("Navision XAL", "Udskriftsmuligheder") then
    $Count = $Count + 1
    ;GUICtrlSetData($counter, $Count)
    WinWaitNotActive("Navision XAL", "Udskriftsmuligheder")
    EndIf
If $count = 37 Then
    MsgBox(16, "Warning", "Om ca. 2 følgeseddler kommer følgeseddels fejlen") ;
    $Count = 0
   
EndIf
EndFunc

Hope this is helpful. Cheers!

Sorry sorry for this extreem late reply

I forgot this tropic - i dumbed the script, the server coulden handel it :D

But thx for alle the sugg's..

/Rex

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...