Created
November 29, 2022 07:04
-
-
Save QQBoxy/35a3abba99a17d9b33fdc8974055b706 to your computer and use it in GitHub Desktop.
前後端測時間效率
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { performance } = require('perf_hooks'); | |
// 前端為 `window.performance` | |
// 後端為 `const { performance } = require('perf_hooks');` | |
const func = (n) => { | |
return ((1 + n) * n) / 2; | |
}; | |
const start = performance.now(); | |
func(1000000); | |
const end = performance.now(); | |
console.log("milliseconds:", end - start); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment