Does uuid random ID generating function add more overhead than a custom function?

Viewed 15

I'm wondering if the UUID library adds more overhead than a custom function like this.

  function generateRandomId() {
    const timeNow = new Date() / 1000;
    const numericId = `${Math.floor(Math.random() * 10 ** 18 + timeNow)}`;
    let alphanumericId = numericId.split("");

    for (let i = Math.floor(Math.random() * numericId.length); i > 0; i--) {
      alphanumericId.splice(i, 1, String.fromCharCode(97 + Number(alphanumericId[i])));
    }
    return alphanumericId.join("");
  }

Also, can you suggest any VScode plugins that would show the size/performance of functions?

Thank you

0 Answers
Related