【JS】【TS】処理時間計測 ~ performance.now() ~

■ はじめに

小ネタ。

以下の関連記事でも使った処理時間計測用の
メソッド「performance.now()」について、メモ。

https://dk521123.hatenablog.com/entry/2021/01/16/202822

■ performance.now()

* ミリ秒の小数点以下まで計測できる

詳細は、以下のサイトを参照。

https://pisuke-code.com/javascript-measure-processing-time/
https://maku77.github.io/js/time/performance-now.html

公式サイト
https://developer.mozilla.org/ja/docs/Web/API/Performance/now

■ サンプル

const startTime = performance.now();

// 計測したい処理
doSomething();

const endTime = performance.now();
console.log("Time : " + (endTime - startTime));

関連記事

非同期処理 ~ async/await, Promise ~
https://dk521123.hatenablog.com/entry/2021/01/16/202822