Tests:
  • Template string slicing

    x
     
    const id = '10135533-2332-4012-aada-b36571a05399';
    `${id.slice(1, 8)}${id.slice(9, 13)}${id.slice(15, 18)}`
  • Array push and join

     
    const id = '10135533-2332-4012-aada-b36571a05399';
    const timeStampParts = []
      const chars = id.split('')
      let index = 0
      for (const char of chars) {
        if (
          (index !== 0 && index < 8) ||
          (index >= 9 && index < 13) ||
          (index >= 15 && index < 18)
        ) {
          timeStampParts.push(char)
        }
        index += 1
      }
    const timestamp = timeStampParts.join('')
  • Array join

     
    const id = '10135533-2332-4012-aada-b36571a05399';
    [id.slice(1, 8), id.slice(9, 13), id.slice(15, 18)].join('')
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Template string slicing
    Array push and join
    Array join

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 years ago)
Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1
Mobile Safari 14 on iOS 14.0
View result in a separate tab
Test name Executions per second
Template string slicing 261411760.0 Ops/sec
Array push and join 1192845.9 Ops/sec
Array join 6990646.0 Ops/sec