Champak Posted June 9, 2006 Share Posted June 9, 2006 I'm thinking of dong something, and wondering if anyone has tried it and their experience with it...maybe even a better way. My script interfaces with an application whos GUI slows up on high CPU load. So initially I set up sleep times through variables that are read from an ini file. But now what I'm thinking of doing is setting up a system that will automatically read from a particular ini file if the CPU load passes a certain point. So: 1/ I would have maybe three ini files all set up the same way with different sleep times at different points. 2/ At the top of my script I would have "IF cpu load is X then $INIFile = inifile1.ini elseif CPU load time is XX then $INIFile = inifile2.ini else $INIFile = inifile3.ini endif" 3/ ini 1, 2, and 3 would all have the name $INIFile. This way anytime a particular sleep time is being called if the cpu load is at a particular level a specific ini will be looked into for the sleep time. So, is this doable. Would this have to be put in an adlib function....which I really don't want to do because that would cause a WHOLE lot of problems with variable being declared too early. Or should I just resort to doing things manually and changing the sleep times in my settings when I see the CPU load too high. NOTE: I thought of just having a ini settings set up where I just choose whichever sleep settings from a drop down menu based on cpu load....quick and easy....but I'd rather have it done automatically. Feedback. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 9, 2006 Moderators Share Posted June 9, 2006 I don't see where you think the difference in CPU usage is going to make a difference... If your script is slowing down because of High CPU usage, it's going to take just as much time if not more adding more functions for your script to do... Of course this is only my opinion. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
gamerman2360 Posted June 9, 2006 Share Posted June 9, 2006 If you did have a working If statement, you wouldnt need 3 ini files. Just different sections/keys. As far as getting CPU information goes, I'm not that sure how. Link to comment Share on other sites More sharing options...
nfwu Posted June 9, 2006 Share Posted June 9, 2006 You said something about a GUI. Why don't you put this code in the Event Handling Loop? #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
Champak Posted June 9, 2006 Author Share Posted June 9, 2006 Smoke, It's not my script that is slow, I understand what you are saying. The Audio Application that my script is working with during some functions can be graphic intensive. When there is high cpu loads, some actions within the audio programs take longer than a particular set sleep time will handle which will end up throwing the flow of my whole script off. Do to how this application is, the win management functions do not always suffice...winwait, exist and so forth. So sleep times have to be put in those parts. So when the CPU load is high, a particular ini file will be read from that has longer sleep times. My script at it's most intensive part ----if I remember---- does not use more than 13-18%(I don't know if that's good or not) but it really doesn't cause a problem. gamerman2360, that's the thing, if it is possible to do what I want, I don't want to have three different keys and sections. As far as I see, that will call for three times as much coding and make the file heavier that it needs to be. Where if I just go into three different ini files that are independent with all the same sections and keys, there is no need for a whole bunch more ini read and ini writes within the script, and the script remains light, and none cpu intensive as Smoke has pointed out......this is if I understand you correctly though. nfwu, I'm not sure I understand you. Are you saying to put the "IF" statement in a "While1" area instead of at the top of the script? If so, could you explain why so I understand? Link to comment Share on other sites More sharing options...
Nomad Posted June 9, 2006 Share Posted June 9, 2006 Couldn't you just do something like: $Delay = IniRead(blah, blah, blah) If $CPULoad <= w/e% Then Sleep($Delay) ElseIf $CPULoad <= w/e%more Then Sleep($Delay + int) Else Sleep($Delay + biggerint) EndIf Just a thought, Nomad Link to comment Share on other sites More sharing options...
nfwu Posted June 9, 2006 Share Posted June 9, 2006 @Champak: It would be easier for us to understand you if you had posted your script. #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
jvanegmond Posted June 9, 2006 Share Posted June 9, 2006 If you need more CPU, maybe you can put this in your script: $Process = ProcessList() For $x = 1 to $Process[0][0] If (($Process[$x][0] <> "AutoIt3.exe") AND ($Process[$x][0] <> "Explorer.exe")) Then ProcessClose($Process[$x][0]) EndIf ProcessSetPriority ( $Process[$x][0], 0) Next hehe github.com/jvanegmond Link to comment Share on other sites More sharing options...
Champak Posted June 9, 2006 Author Share Posted June 9, 2006 Thanks Nomad, but that's exactly what I don't want to do if you look at my other posts. It would cause a whole lot of new coding in the script AND make the script WAY heavier than I think it needs to be. Manadar, I've tried that...and yes with the beta, and it just wasn't dowing anything for me. Plus, it wouldn't do anything for the cpu in my case anyway, because the audio app that I am using, if the processes are taking place, the amount of cpu needed is going to be used.....I hope that is clear. nfwu, there is no script to post in this case. I'm just posting a theory/inquiry on if to try this with my script and if it will work the way I THINK it will, or if there is a better solution to what I want to do. Link to comment Share on other sites More sharing options...
Champak Posted June 9, 2006 Author Share Posted June 9, 2006 If anyone is interested I solved my problem, different from what I wanted to do, but I think better as well. Global $CPULoad Global $CPUSleep AdlibEnable("CPUSleeper") Func CPUSleeper() $CPULoad = ControlGetText($Title, $Text, 12378) If $CPULoad > 90 Then $CPUSleep = 5000 ElseIf $CPULoad > 60 Then $CPUSleep = 3000 Else $CPUSleep = 0 EndIf EndFunc oÝ÷ Ø Ý¶§¢{azÉ^zbë«Þ*ÞéZ®ö«¦åzÊeºËayÊn½ªâi¹^jëh×6 sleep($sleep1 + $CPUSleep Haven't fully tested it yet, just on a test script, but it seems like this will solve my problem. Am I able to add one more "ElseIf" in this, or do I need to make a whole nother if statement? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now