From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/ja/web/api/performance/now/index.html | 103 ++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 files/ja/web/api/performance/now/index.html (limited to 'files/ja/web/api/performance/now') diff --git a/files/ja/web/api/performance/now/index.html b/files/ja/web/api/performance/now/index.html new file mode 100644 index 0000000000..2c77a37538 --- /dev/null +++ b/files/ja/web/api/performance/now/index.html @@ -0,0 +1,103 @@ +--- +title: performance.now() +slug: Web/API/Performance/now +tags: + - API + - Method + - Performance + - Reference + - Web Performance API +translation_of: Web/API/Performance/now +--- +
{{APIRef("High Resolution Timing")}}
+ +

performance.now() メソッドは、ミリ秒単位で計測された {{domxref("DOMHighResTimeStamp")}} を返します。

+ +
+

タイムスタンプは実際には高解像度ではありません。Spectre のようなセキュリティ上の脅威を軽減するために、ブラウザは現在、さまざまな程度まで結果を丸めています (Firefox は Firefox 59 から 2 ミリ秒に丸めています)。ブラウザによっては、タイムスタンプを少しランダム化するものもあります。 精度は将来のリリースで改善されることでしょう。ブラウザの開発者は、これらのタイミング攻撃と、それを軽減する最善策について調査しています。

+
+ +

{{AvailableInWorkers}}

+ +

戻り値は、time origin からの経過時間を表します。

+ +

次の点に留意してください:

+ + + +

構文

+ +
t = performance.now();
+ +

+ +
var t0 = performance.now();
+doSomething();
+var t1 = performance.now();
+console.log("Call to doSomething took " + (t1 - t0) + " milliseconds.");
+
+ +

JavaScript で利用できる他のタイミングデータ (例えば Date.now) とは違い、 performance.now() が返すタイムスタンプは、1ミリ秒の分解能に制限されません。その代わりに、マイクロ秒までの精度を持った浮動小数点の値で表します。

+ +

また、Date.now() とは違い、performance.now() が返す値は、常に一定の割合で増加します。システムクロック (これはマニュアルで調整、またはNTPのようなソフトウェアで変えられているかもしれません) から独立しているのです。他方で performance.timing.navigationStart + performance.now() は、おおよそ Date.now() と同じになるでしょう。

+ +

時間精度の引き下げ

+ +

タイミング攻撃やフィンガープリンティングから保護するため、ブラウザの設定によっては、performance.now() の精度が丸められることがあります。
+Firefoxでは、privacy.reduceTimerPrecision の設定がデフォルトで有効になっており、Firefox 59 ではデフォルトで 20 us (マイクロ秒) に設定されています。 Firefox 60 では 2 ms (ミリ秒) になります。

+ +
// Firefox 60 での時間精度の引き下げ (2ms)
+performance.now();
+// 8781416
+// 8781814
+// 8782206
+// ...
+
+
+// `privacy.resistFingerprinting` 有効化による時間精度の引き下げ`
+performance.now();
+// 8865400
+// 8866200
+// 8866700
+// ...
+
+ +

Firefoxでは privacy.resistFingerprinting も有効にできます。これは、精度を 100 ms か privacy.resistFingerprinting.reduceTimerPrecision.microseconds のどちらか大きい方へ変更します。

+ +

仕様

+ + + + + + + + + + + + + + + + + + + +
仕様書策定状況コメント
{{SpecName('Highres Time Level 2', '#dom-performance-now', 'performance.now()')}}{{Spec2('Highres Time Level 2')}}インターフェイスと型について、より厳密な定義
{{SpecName('Highres Time', '#dom-performance-now', 'performance.now()')}}{{Spec2('Highres Time')}}初期定義
+ +

ブラウザー実装状況

+ + + +

{{Compat("api.Performance.now")}}

+ +

関連情報

+ + -- cgit v1.2.3-54-g00ecf