lod
New Member
I feel like a true programmer being a BASIC beginner
Posts: 16
|
Post by lod on Sept 18, 2018 10:49:52 GMT -5
Hi, I was looking for the formula to get the local cpu speed in ghz. It was first for javascript but I couldn't find one that I can understand. But when all light get down there rises the torch. Can I display it under Liberty Basic ? I think today's websites are very "hungry", many fps with the banners, interactive widget … it could be useful to have such a script to route users by their cpu speed. Right ?
|
|
|
Post by Rod on Sept 18, 2018 11:27:49 GMT -5
You could simply time a few thousand computations to get a feel for how fast the machine is. But what would you change to make the situation any better? Not sure I understand the question/task in hand.
|
|
lod
New Member
I feel like a true programmer being a BASIC beginner
Posts: 16
|
Post by lod on Sept 19, 2018 1:41:15 GMT -5
I don't understand too your idea.A loop with a timer in milliseconds ? I mean today's website turn to be as nice and complex as video games and so it could be useful to know users cpu's capacities before loading all the widget. A bit like a script that detects the browser and so on ... Maybe I try to enforce an open door though. It seems so obvious. Thanks
|
|
|
Post by Rod on Sept 19, 2018 3:26:47 GMT -5
The number of Liberty BASIC computations you can achieve per millisecond will indicate the processor speed. However Google states that the high performance counter can be used to check speed. Alyce published this routine a while back. It seems to confirm my processor speed.
struct res, lowPart as ulong, highPart as long
'see if system has a high frequency counter calldll #kernel32, "QueryPerformanceFrequency",_ res as struct, result as boolean
if result=0 then print "System doesn't support hi-res counter." end else freq=largeInt2Dec(res.lowPart.struct, res.highPart.struct) calldll #kernel32, "QueryPerformanceCounter",_ res as struct, result as boolean first=largeInt2Dec(res.lowPart.struct, res.highPart.struct) calldll #kernel32, "QueryPerformanceCounter",_ res as struct, result as boolean second=largeInt2Dec(res.lowPart.struct, res.highPart.struct) print "Frequency in counts per second: ";freq print "First value: ";first print "Second value: ";second print "Time (ticks) ellapsed: ";second-first end if end
function largeInt2Dec(low, high) lowHex$ = right$("0000" + dechex$(low), 4) highHex$ = right$("0000" + dechex$(high), 4) largeInt2Dec = hexdec(highHex$ + lowHex$) end function
|
|
|
Post by Rod on Sept 19, 2018 3:32:30 GMT -5
This code for example gives me a result of 185413 loops on a 1.7Gh processor. It should vary by processor speed.
t=time$("ms")+1000 while time$("ms")<t c=c+1 wend print c
|
|
lod
New Member
I feel like a true programmer being a BASIC beginner
Posts: 16
|
Post by lod on Sept 19, 2018 4:33:58 GMT -5
Thank you. I gonna try it.
|
|
|
Post by metro on Sept 19, 2018 6:24:45 GMT -5
I have a Dell OptiPlex 990 - MT - Core i7 2600 3.4 GHz - 8GB memory Linux mint sees it as Quad core Intel Core i7-2600 (-MT-MCP-) arch: Sandy Bridge rev.7 cache: 8192 KB flags: (lm nx sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx) bmips: 27139 clock speeds: min/max: 1600/3800 MHz 1: 2722 MHz 2: 2402 MHz 3: 2440 MHz 4: 2535 MHz 5: 3008 MHz 6: 2557 MHz 7: 3135 MHz 8: 2696 MHz
running Rod's code result is 230614
|
|
lod
New Member
I feel like a true programmer being a BASIC beginner
Posts: 16
|
Post by lod on Sept 19, 2018 8:54:20 GMT -5
With the loop the result 4 me is 236395
I'm running an Intel Core i7 6700hq @ 2.6ghz 8go RAM
I tried 2 run the big code as is but it didn't launch. BASIC Compile Halted : array largeInt2Dec is 'one" dommensional
How did you get so much information about your cpu ? Did you use a diagnostique software or are these the infos provided by your OS?
|
|
|
Post by Rod on Sept 19, 2018 9:58:40 GMT -5
You need to scroll down and capture all of the code I posted, you are missing the function code.
Type sysinfo into your Win10 searchbox to get your system info.
|
|
lod
New Member
I feel like a true programmer being a BASIC beginner
Posts: 16
|
Post by lod on Sept 19, 2018 10:14:13 GMT -5
Shame on me I get Frequency in counts per second: 40878 First value: 9644073 Second value: 9670415 Time (ticks) ellapsed: 26342 Thank you
|
|
|
Post by Brandon Parker on Sept 20, 2018 8:34:59 GMT -5
Another, and possibly more reliable method, would be to call the CallNtPowerInformation function within the "PowrProf.dll" in Windows. It's fairly straight forward if you know how many processors you have. For systems with more than one processor you just have to extend the structure. Without getting in to how to programmatically determine the number of processors and building the structure on the fly here is some code that should work. The code below was created for a 4 processor system, but it will work on systems with fewer processors; the unused sections of the structure will just be zeros. For a system with more than 4 processors you just have to add a whole new set of parameters to the structure. You can find more about this at the following locations: CallNtPowerInformationPROCESSOR_POWER_INFORMATION structureOpen "PowrProf.dll" For DLL As #PowrProf
ProcessorInformation = 11
Struct ProcessorPowerInfo, Number0 As ulong, _ MaxMhz0 As ulong, _ CurrentMhz0 As ulong, _ MhzLimit0 As ulong, _ MaxIdleState0 As ulong, _ CurrentIdleState0 As ulong, _ 'This is the end if you only have one processor Number1 As ulong, _ MaxMhz1 As ulong, _ CurrentMhz1 As ulong, _ MhzLimit1 As ulong, _ MaxIdleState1 As ulong, _ CurrentIdleState1 As ulong, _ 'This is the end if you only have two processors Number2 As ulong, _ MaxMhz2 As ulong, _ CurrentMhz2 As ulong, _ MhzLimit2 As ulong, _ MaxIdleState2 As ulong, _ CurrentIdleState2 As ulong, _ 'This is the end if you only have three processors Number3 As ulong, _ MaxMhz3 As ulong, _ CurrentMhz3 As ulong, _ MhzLimit3 As ulong, _ MaxIdleState3 As ulong, _ CurrentIdleState3 As ulong
BufferLen = Len(ProcessorPowerInfo.struct)
CallDLL #PowrProf, "CallNtPowerInformation", ProcessorInformation As long, _ _NULL As ulong, _ _NULL As ulong, _ ProcessorPowerInfo As struct, _ BufferLen As ulong, _ statusReturn As long
Print "Processor # - ";ProcessorPowerInfo.Number0.struct Print "Max Mhz - ";ProcessorPowerInfo.MaxMhz0.struct Print "Current Mhz - ";ProcessorPowerInfo.CurrentMhz0.struct Print "Mhz Limit - ";ProcessorPowerInfo.MhzLimit0.struct Print "Max Idle State - ";ProcessorPowerInfo.MaxIdleState0.struct Print "Current Idle State - ";ProcessorPowerInfo.CurrentIdleState0.struct Print Print "Processor # - ";ProcessorPowerInfo.Number1.struct Print "Max Mhz - ";ProcessorPowerInfo.MaxMhz1.struct Print "Current Mhz - ";ProcessorPowerInfo.CurrentMhz1.struct Print "Mhz Limit - ";ProcessorPowerInfo.MhzLimit1.struct Print "Max Idle State - ";ProcessorPowerInfo.MaxIdleState1.struct Print "Current Idle State - ";ProcessorPowerInfo.CurrentIdleState1.struct Print Print "Processor # - ";ProcessorPowerInfo.Number2.struct Print "Max Mhz - ";ProcessorPowerInfo.MaxMhz2.struct Print "Current Mhz - ";ProcessorPowerInfo.CurrentMhz2.struct Print "Mhz Limit - ";ProcessorPowerInfo.MhzLimit2.struct Print "Max Idle State - ";ProcessorPowerInfo.MaxIdleState2.struct Print "Current Idle State - ";ProcessorPowerInfo.CurrentIdleState2.struct Print Print "Processor # - ";ProcessorPowerInfo.Number3.struct Print "Max Mhz - ";ProcessorPowerInfo.MaxMhz3.struct Print "Current Mhz - ";ProcessorPowerInfo.CurrentMhz3.struct Print "Mhz Limit - ";ProcessorPowerInfo.MhzLimit3.struct Print "Max Idle State - ";ProcessorPowerInfo.MaxIdleState3.struct Print "Current Idle State - ";ProcessorPowerInfo.CurrentIdleState3.struct
Close #PowrProf
{:0) Brandon R. Parker
|
|
lod
New Member
I feel like a true programmer being a BASIC beginner
Posts: 16
|
Post by lod on Oct 14, 2018 2:38:46 GMT -5
Good reading but it’s far out of my sight. I don’t understand the dlls. I know that they are fundamentals in a system. I can’t tell how many "missig dll" message I have ran into. Thank you Doc
|
|