JSON test

Benchmark created on


Test runner

Ready to run.

Testing in WebKit 537.36 / undefined
TestOps/sec
JSON.stringify whole array
const arr = [];
for (let i = 0; i < 5000; i++) {
  arr.push(["67f43166-abfc-4521-a6f1-b1209b6f78f2", {
    accountTag: "778d550f-9996-4934-920e-3f278bcd9f69",
    deviceId: "67f43166-abfc-4521-a6f1-b1209b6f78f2",
    deviceRegistration: "7d2e35a1-cb96-4fdb-938c-931cfcf2e068",
    userId: "5cb33792-38ca-4e9a-bc5a-c8ce75fed64f",
    userEmail: "user@company.com",
    clientPlatform: "mac",
    clientVersion: "2023.5.589",
  }, Date.now()]);
}
console.log(JSON.stringify(arr))
ready
No intermediate array
let buffer = "[";
let first = true;
for (let i = 0; i < 5000; i++) {
  if (!first) buffer += ",";

  buffer += JSON.stringify([
    "67f43166-abfc-4521-a6f1-b1209b6f78f2",
    {
      accountTag: "778d550f-9996-4934-920e-3f278bcd9f69",
      deviceId: "67f43166-abfc-4521-a6f1-b1209b6f78f2",
      deviceRegistration: "7d2e35a1-cb96-4fdb-938c-931cfcf2e068",
      userId: "5cb33792-38ca-4e9a-bc5a-c8ce75fed64f",
      userEmail: "user@company.com",
      clientPlatform: "mac",
      clientVersion: "2023.5.589",
    },
    Date.now(),
  ]);
}
buffer += "]";
console.log(`buffer: `, buffer);
ready

Revisions

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