structuredClone of huge data (v2)

Revision 2 of this benchmark created on


Setup

const count = 500000;
const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-.,_:;#+*'?=)(/&%$!";

function randomString(size) {
	var string = "";
	for ( let i = 0; i < size; i++ ) {
		string += chars[Math.floor(Math.random() * chars.length)];
	}
	
	return string;
}

var hugeArrayOfObjects = [];
for ( let i = 0; i < count; i++ ) {
	hugeArrayOfObjects.push({
		lon: Math.random() * 360 - 180,
		lat: Math.random() * 180 - 90,
		a: randomString(32),
		b: randomString(16),
		c: randomString(48),
	});
}

var hugeArrayOfStrings = [];
for ( let i = 0; i < count; i++ ) {
	const src = hugeArrayOfObjects[i];

	hugeArrayOfStrings.push([src.lon, src.lat, src.a, src.b, src.c].join(";"));
}

var hugeTypedArray = new Uint32Array(3 * count);
for ( let i = 0, write = 0; i < count; i++ ) {
	const src = hugeArrayOfObjects[i];

	hugeTypedArray[write++] = i;
	hugeTypedArray[write++] = Math.round( src.lon * 10000000 ) - 0x80000000;
	hugeTypedArray[write++] = Math.round( src.lat * 10000000 ) - 0x80000000;
}

var hugeString = hugeArrayOfStrings.join("|");

Test runner

Ready to run.

Testing in
TestOps/sec
one huge string
const a = structuredClone(hugeString);
ready
huge array of string
const b = structuredClone(hugeArrayOfStrings);
ready
huge array of objects
const c = structuredClone(hugeArrayOfObjects);
ready
huge typed array
const c = structuredClone(hugeTypedArray);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.