seedId

Benchmark created on


Setup

const label = '12345678901234567890'

Test runner

Ready to run.

Testing in
TestOps/sec
map
Array.from(label)
    // min 16 long
    .concat(Array(16).fill('\u0000'))
    // max 16 long
    .slice(0, 16)
    .map((chr, idx) => `${[4, 6, 8].includes(idx) ? '-' : ''}${chr.charCodeAt(0).toString(16).padStart(2, '0')}`)
    .join('')
ready
reduce
Array.from(label)
    // min 16 long
    .concat(Array(16).fill('\u0000'))
    // max 16 long
    .slice(0, 16)
    .reduce(
    (hsh, chr, idx) => `${hsh}${[4, 6, 8].includes(idx) ? '-' : ''}${chr.charCodeAt(0).toString(16).padStart(2, '0')}`,
    '',
  )
ready
reduce spread
[...label.slice(0, 16).padEnd(16, String.fromCharCode(0))]
  .reduce(
    (hsh, chr, idx) => `${hsh}${[4, 6, 8].includes(idx) ? '-' : ''}${chr.charCodeAt(0).toString(16).padStart(2, '0')}`,
    '',
  )
ready

Revisions

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