js獲取一個函式執行時間
阿新 • • 發佈:2021-02-04
關鍵詞:時間戳
這裡隨便瞎寫了個for迴圈10000次向arr中新增內容
let arr = [] function testFun() { let start = new Date().getTime() for (let index = 0; index < 10000; index++) { arr.push(index) // ...Do something } let end = new Date().getTime() console.log("開始:", start) console.log("結束:", end) console.log("花費:", end - start) } testFun()