@akbooer said in Using luup.call_delay() in the browser code test boxes:
This variation in delays is to be expected, since the system IS doing other things.
Yep - appreciate that. I did a few tests and found a plugin that was being accessed very regularly and was doing this in a for loop of varying loop count/length - and then the json then being processed by openLuup:
lul_json = lul_json .. '{"Id":'..v.Id..',"LastRec":'..v.LastRec..',"LastVal":"'..v.LastVal..'"}'
and changed it to this and then a table.concat later:
table.insert(lul_json, '{"Id":')
table.insert(lul_json, v.Id)
table.insert(lul_json, ',"LastRec":')
table.insert(lul_json, v.LastRec)
table.insert(lul_json, ',"LastVal":"')
table.insert(lul_json, v.LastVal)
table.insert(lul_json, '"}')
Made a substantial difference as we know a dot dot string concat is very slooow; especially when chained from one string to the next. It may be even faster to not use table.insert but a straight
lul_json[count] = xyz
count = count+1
So the luup.call_delay() test routine above can be helpful in finding errant plugins, etc.
Roger on the test window and using require: I have my thousand lines in the test window and another 500 line coming in from a require and all works fine!!