getGclid

Benchmark created on


Setup

let gclid = '';
let jobPayload = {
  submissionId: 'f93f9e3a-cd88-4567-868e-fd95afe6a2b1',
  'field:gclid': 'test-gcl49203-gsdes3-4w34',
};

const externalIdObject = {
  submissionId: jobPayload.submissionId,
  gclid: jobPayload['field:gclid'],
};
const stringifiedObject = JSON.stringify(externalIdObject);

Test runner

Ready to run.

Testing in
TestOps/sec
filter
if (stringifiedObject.includes('gclid')) {
  const externalIdValues = stringifiedObject.split('"');
  const filteredValues = externalIdValues.filter(val => !['{', '}', ':', ','].includes(val));
  gclid = filteredValues[filteredValues.length - 1];
}
ready
replace colon
if (stringifiedObject.includes('gclid')) {
  const parsedValues = stringifiedObject.replaceAll(/[{",}]/g, '');
  const filteredValues = parsedValues.split(':');
  gclid = filteredValues[filteredValues.length - 1];
}
ready

Revisions

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