Public
Edited
Sep 5, 2022
2 stars
Insert cell
Insert cell
N = 1e7
Insert cell
// 21 to 25 bytes per record
{
const a = performance.memory.usedJSHeapSize;

const s = new Set();
for (let i = 0; i < N; ++i) s.add(i);

return (performance.memory.usedJSHeapSize - a)/N;
}
Insert cell
// 30 to 40 bytes
{
const a = performance.memory.usedJSHeapSize;
const s = new Map();
for (let i = 0; i < N; ++i) s.set(i, i);
return (performance.memory.usedJSHeapSize - a) / N;
}
Insert cell
// 12+ bytes
{
const a = performance.memory.usedJSHeapSize;
const s = new Array();
for (let i = 0; i < N; ++i) s[i] = i;
return (performance.memory.usedJSHeapSize - a) / N;
}
Insert cell
// 4 bytes
{
const a = performance.memory.usedJSHeapSize;
const s = new Uint32Array(N);
for (let i = 0; i < N; ++i) s[i] = i;
return (performance.memory.usedJSHeapSize - a) / N;
}
Insert cell
// 8 bytes
{
const a = performance.memory.usedJSHeapSize;
const s = new Float64Array(N);
for (let i = 0; i < N; ++i) s[i] = i;
return (performance.memory.usedJSHeapSize - a) / N;
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more