DonationCoder.com Software > Finished Programs
DONE: Replacement Power Options applet
Carol Haynes:
I still get large negative usage values (eg. -80% even when CPU usage is under 10%)
skrommel:
:tellme: How about LowToSleep v1.2?
Skrommel
f0dder:
Hm, some things... unless I pass parameters for all three variables to GetSystemTimes, it doesn't return anything - the following code would simply print fluff! with SysInternals' dbgview. Adding "dummy1" and "dummy2", I get some garbage output, indicating that there's output.
--- ---lala = %idleticks% + "fluff!"
DllCall("kernel32.dll\OutputDebugString", "uint", &lala)
(christ, AutoHotKey is a weird language).
I still get -100% usage, though - and I'm pretty sure affinity isn't the problem, GetSystemTimes shouldn't be affected by that (rdtsc, GetTickCount() and QueryPerformanceCounter() are, though - I originally thought you were using one of those).
What the heck is going on in the loop in GETCPULOAD?
EDIT: oh, A_TickCount probably translates to a call to GetTickCount(), so affinity might be necessary after all. And the Loop seems to be necessary because of AHK's weird "everything is a string, but we don't translate API output" philosophy. Hm.
EDIT2: I've modified the GETCPULOAD() function somewhat...
--- ---GETCPULOAD() ;originally made by shimanov
{
Global
idletime0 = %idletime% ; Save previous values
tick0 = %tick%
DllCall("Kernel32.dll\GetSystemTimes", "*UInt64", idletime, "*Uint64", dummy1, "*Uint64", dummy2)
tick := A_TickCount
dIdle := (idletime - idletime0)
dTick := (tick - tick0)
load := 100 - 0.01 * dIdle/dTick
outstr = Spent time: %dIdle%/%dTick%
DllCall("kernel32.dll\OutputDebugString", "str", outstr)
Return,load
}
With dbgview, I get values like...
--- ---Spent time: 20000000/1000
Spent time: 20000000/1000
Spent time: 19843750/1000
Spent time: 20000000/1000
Spent time: 19843750/1000
Spent time: 20000000/1000
Spent time: 19687500/1000
EDIT 3: Okay, I should have seen this earlier. Quoting MSDN for GetSystemTimes, emphasis is mine: "Retrieves system timing information. On a multiprocessor system, the values returned are the sum of the designated times across all processors.".
So, for NT systems, add a EnvGet, NumCpu, NUMBER_OF_PROCESSORS near the top of the script, and do dIdle := (idletime - idletime0) / NumCpu. Feels somewhat hacky, but works. Probably better using GetSystemInfo() and checking the dwNumberOfProcessors field, but I dunno how AHK handles structs. If you do the environment thing, check for 9x and assign 1 to NumCpu.
Carol Haynes:
Sounds like progress - but I don't pretend I have followed the argument :-[
CodeTRUCKER:
I'll take a shot at it. I think what is going on is to use the internal "clock" counts to a certain quantity defined by... I'm not sure, but the countdown/up is what triggers the event. Clear as mud, right?
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version