Parsing Script Tag Benchmark Test

Benchmark created on


Description

LSKD Code Test - Floven C. Catalasan

Test runner

Ready to run.

Testing in
TestOps/sec
String Split by colon + Array Reduce
const str = "script=bundle:id=1589427400:value=21995:count=4:index=4";
  for (let i = 0; i < 1000000; i++) {
    const records = str.split(":").reduce((acc, part) => {
      const [key, value] = part.split("=");
      acc[key] = value;
      return acc;
    }, {});
  }
ready
String Split by RegEx
const str = "script=bundle:id=1589427400:value=21995:count=4:index=4";
const regex = /script=bundle:id=(\d+):value=(\d+):count=(\d+):index=(\d+)/;
for (let i = 0; i < 1000000; i++) {
    const match = str.split(regex);
  }
ready
RegEx Match
const str = "script=bundle:id=1589427400:value=21995:count=4:index=4";
const regex = /script=bundle:id=(\d+):value=(\d+):count=(\d+):index=(\d+)/;
for (let i = 0; i < 1000000; i++) {
    const match = str.match(regex);
  }
ready

Revisions

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