Basically, if a value is an integer between -32768 and -32767, it packs it into the same variable block as the variable name. That means that normal sparse arrays and objects are now twice as efficient when filled with small integers.
This is a pretty big change - It passes all the tests but there may still some issues when running code - If anyone can come up with a simple code example that shows up problems it'd be greatly appreciated!
A quick example of the improvements:
var obj = {
a:63,
b:100,
c:42 };
function f3(a,b,c,d) { print(process.memory().usage); }
function f2(a,b,c,d) { f3(a,b,c,d); }
function f1(a,b,c,d) { f2(a,b,c,d); }
print(process.memory().usage);
f1("Hello","There","World","");
f1(1,2,3,4);
setTimeout("print(process.memory().usage);", 1);
Old: 53, 75, 74, 63
New: 50, 72, 67, 58
So:
Objects/arrays take up less space
Calling functions with integers takes less space
Timers take less space (especially if the interval is <32ms)
@BogdanG will be happy anyway - finally something that improves memory usage on the VLdiscovery!
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi - I thought some of you might be interested in the packed_array branch I just uploaded. I've made a build of it at http://www.espruino.com/binaries/espruino_1v65_espruino_1r3_packed_array_beta.bin
Basically, if a value is an integer between -32768 and -32767, it packs it into the same variable block as the variable name. That means that normal sparse arrays and objects are now twice as efficient when filled with small integers.
This is a pretty big change - It passes all the tests but there may still some issues when running code - If anyone can come up with a simple code example that shows up problems it'd be greatly appreciated!
A quick example of the improvements:
So:
@BogdanG will be happy anyway - finally something that improves memory usage on the VLdiscovery!