Suppose I want to compare the efficiency of storing bits of a static canvas/image with Alpha more or less than 0.5 using an "array of array of number" versus an "array of string," which would be better in terms of memory usage and speed?
var c = $('myCanvas');
var d = c[0].getContext('2d').getImageData().data;
// access: d[3+4*(c.width()*y+x)] >= 0.5
vs
var n = [ [ 2147483647, 2147483647, 2147483647 ], [ 0, 0, 0 ], ... ]
// access: n[y][x/31|0] >> x%31 & 1
vs
var s = [ [ 255, 255, 255, 255, ... ].to_s(), [ 0, 0, 0, 0, ...].to_s(), ... ]
// access: n[y].charCodeAt(x/8|0) >> x%8 & 1
Please note that `to_s()` is a custom function to convert an array of bytes into a string similar to this one:
These codes are for demonstration purposes only, as I will implement the concept later. My question is, how can I measure the memory usage of d, n, and s?