Increase CPU Frequency
Posted: Sat Jan 24, 2015 5:03 pm
Code: Select all
static int node_set_cpu_freq( lua_State* L )
{
uint32_t new_freq = luaL_checkinteger( L, 1 );
if(new_freq == 160){
REG_SET_BIT(0x3ff00014, BIT(0));
os_update_cpu_frequency(160);
}else{
REG_CLR_BIT(0x3ff00014, BIT(0));
os_update_cpu_frequency(80);
}
new_freq = ets_get_cpu_frequency();
lua_pushinteger(L, new_freq);
return 1;
}
This is supposed to increase cpu freq from 80 to 160. However, I do not see any differences in execution speed with the following benchmark:
Code: Select all
function runOnce(freq)
sum = 0
node.set_cpu_freq(freq)
for runs=0,4 do
now=tmr.now()
a = 0
b = 2
c = 1
for ii=0,10 do
for i=0,1000 do
a = i+b
c = bit.bxor(c, 1)
tmr.wdclr()
node.set_cpu_freq(freq)
end
end
nnow = tmr.now()
timeDiff = (nnow-now)/1000
sum = sum + timeDiff
print("time needed: " .. timeDiff )
end
print("total time needed: " .. sum)
end
print("======================")
freq=node.setcpufreq(80)
print("Setting CPU FREQUENCY TO " .. freq .. "MHz")
runOnce(80)
print("======================")
print("======================")
freq=node.setcpufreq(160)
print("Setting CPU FREQUENCY TO " .. freq .. "MHz")
runOnce(160)
print("======================")
Maybe someone else has an idea? tmr.now() is supposed to return the system time in micro seconds. Maybe the system time runs faster at 160MHz?