我正在使用最新的固件,0.9.6-dev_20150704,浮动版本(https://github.com/nodemcu/nodemcu-firmware/releases)
这段代码一开始需要 62-63 毫秒才能完成,并且每次连续运行代码似乎都会增加几分之一毫秒,在执行了几百次之后,它几乎达到了 100 毫秒。它从来没有撞到我身上。
function save_setting(name, value)
file.open(name, 'w') -- you don't need to do file.remove if you use the 'w' method of writing
file.writeline(value)
file.close()
end
function read_setting(name)
if (file.open(name)~=nil) then
result = string.sub(file.readline(), 1, -2) -- to remove newline character
file.close()
return true, result
else
return false, nil
end
end
startTime = tmr.now()
test1 = 1200
test2 = 15.7
test3 = 75
test4 = 15000001
save_setting('test1', test1)
save_setting('test2', test2)
save_setting('test3', test3)
save_setting('test4', test4)
1exists, test1 = read_setting('test1')
2exists, test2 = read_setting('test2')
3exists, test3 = read_setting('test3')
4exists, test4 = read_setting('test4')
completeTime = (tmr.now()-startTime)/(1000)
print('time to complete (ms):')
print(tostring(completeTime))