From e8ec59b1086fa7c5f58c7482c4dcfd6fb7bd648b Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Tue, 22 Feb 2022 22:55:31 +0900 Subject: 2022/02/18 時点の英語版に同期 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- files/ja/web/api/performance/mark/index.md | 101 ++++++++++++----------------- files/ja/web/api/performance/now/index.md | 90 +++++++++++++------------ 2 files changed, 90 insertions(+), 101 deletions(-) (limited to 'files/ja') diff --git a/files/ja/web/api/performance/mark/index.md b/files/ja/web/api/performance/mark/index.md index 1a02bd4154..74e2435288 100644 --- a/files/ja/web/api/performance/mark/index.md +++ b/files/ja/web/api/performance/mark/index.md @@ -3,52 +3,53 @@ title: performance.mark() slug: Web/API/Performance/mark tags: - API - - Webパフォーマンス - メソッド - リファレンス + - ウェブパフォーマンス +browser-compat: api.Performance.mark translation_of: Web/API/Performance/mark --- -
{{APIRef("User Timing API")}}
+{{APIRef("User Timing API")}} -

mark() メソッドは、ブラウザのパフォーマンスエントリバッファに、指定された名前で{{domxref("DOMHighResTimeStamp","timestamp")}} を作成します。アプリケーション定義のタイムスタンプは、{{domxref("Performance")}} インタフェースの getEntries*() メソッド ({{domxref("Performance.getEntries","getEntries()")}}、{{domxref("Performance.getEntriesByName","getEntriesByName()")}} または{{domxref("Performance.getEntriesByType","getEntriesByType()")}}) のいずれかによって取得できます。

+**`mark()`** メソッドは、ブラウザーのパフォーマンスエントリーバッファーに、指定された名前で{{domxref("DOMHighResTimeStamp","timestamp")}} を作成します。 -

{{AvailableInWorkers}}

+アプリケーション定義のタイムスタンプは、{{domxref("Performance")}} インタフェースの `getEntries*()` メソッド ({{domxref("Performance.getEntries","getEntries()")}}、{{domxref("Performance.getEntriesByName","getEntriesByName()")}} または{{domxref("Performance.getEntriesByType","getEntriesByType()")}}) のいずれかによって取得できます。 -

mark の {{domxref("PerformanceEntry","performance entry")}} は、次のプロパティ値を持ちます。

+`mark()` は内部的にデータを {{domxref("PerformanceEntry")}} として格納します。 - +{{AvailableInWorkers}} -

このメソッドに与えられた name が {{domxref("PerformanceTiming")}} インターフェイスにすでに存在する場合、{{jsxref("SyntaxError")}} がスローされます。

+## 構文 -

構文

+```js +performance.mark(name); +performance.mark(measureName, markOptions) +``` -
performance.mark(name);
-
+### 引数 -

引数

+- name + - : {{domxref("DOMString")}} で、マークの名前を表します。このメソッドで指定された `name` がすでに {{domxref("PerformanceTiming")}} インターフェイスに存在していた場合は、 {{jsxref("SyntaxError")}} が発生します。 -
-
name
-
マークの名前を表す {{domxref("DOMString")}}。
-
+- `markOptions` {{optional_inline}} + - : このマークのためにタイムスタンプと追加のメタデータを指定するためのオブジェクトです。 -

戻り値

+ - `detail` + - : マークに含める任意のメタデータです。 + - `startTime` + - : マークの時刻として使用する {{domxref("DOMHighResTimeStamp")}} desu. -
-
void
-
 
-
+### 返値 -

+- entry + - : 生成された {{domxref("PerformanceMark")}} エントリーです。 -

次の例は、mark() を使用して {{domxref("PerformanceMark")}} エントリを作成および取得する方法を示しています。

+## 例 -
// たくさんの mark を作成します。
+次の例は、`mark()` を使用して {{domxref("PerformanceMark")}} エントリーを作成および取得する方法を示しています。
+
+```js
+// たくさんの mark を作成します。
 performance.mark("squirrel");
 performance.mark("squirrel");
 performance.mark("monkey");
@@ -56,46 +57,24 @@ performance.mark("monkey");
 performance.mark("dog");
 performance.mark("dog");
 
-// PerformanceMark エントリをすべて取得します。
+// PerformanceMark エントリーをすべて取得します。
 const allEntries = performance.getEntriesByType("mark");
 console.log(allEntries.length);
 // 6
 
-// "monkey" PerformanceMark エントリをすべて入手します。
+// "monkey" PerformanceMark エントリーをすべて入手します。
 const monkeyEntries = performance.getEntriesByName("monkey");
 console.log(monkeyEntries.length);
 // 2
 
 // すべての mark を消去します。
 performance.clearMarks();
-
- -

仕様

- - - - - - - - - - - - - - - - - - - -
仕様書ステータスコメント
{{SpecName('User Timing Level 2', '#dom-performance-mark', 'mark()')}}{{Spec2('User Timing Level 2')}} -

mark() 処理モデルを明確にします。

-
{{SpecName('User Timing', '#dom-performance-mark', 'mark()')}}{{Spec2('User Timing')}}基本的な定義
- -

ブラウザの互換性

- -
-

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

-
+``` + +## 仕様書 + +{{Specifications}} + +## ブラウザーの互換性 + +{{Compat}} diff --git a/files/ja/web/api/performance/now/index.md b/files/ja/web/api/performance/now/index.md index 2c77a37538..d66a56adf1 100644 --- a/files/ja/web/api/performance/now/index.md +++ b/files/ja/web/api/performance/now/index.md @@ -3,69 +3,80 @@ title: performance.now() slug: Web/API/Performance/now tags: - API - - Method - - Performance - - Reference - - Web Performance API + - メソッド + - パフォーマンス + - リファレンス + - ウェブパフォーマンス API +browser-compat: api.Performance.now translation_of: Web/API/Performance/now --- -
{{APIRef("High Resolution Timing")}}
+{{APIRef("High Resolution Timing")}} -

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

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

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

-
+{{AvailableInWorkers}} -

{{AvailableInWorkers}}

+返値は[時刻原点](/ja/docs/Web/API/DOMHighResTimeStamp#the_time_origin)からの経過時間を表します。 -

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

+次の点に留意してください。 -

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

+- {{domxref("Window")}} コンテキストから生成された専用ワーカー (dedicated worker) では、この値は生成元の window における`performance.now()` の値よりも小さい値になります。従来はメインコンテキストの `t0` と同じでしたが、変更されました。 +- 共有ワーカー (shared worker) またはサービスワーカー (service worker) では、この値はメインコンテキストでの値よりも大きくなるかもしれません。 window はワーカーよりも後に生成される可能性があるからです。 - +ブラウザーは通常、 [Spectre](https://spectreattack.com/) のような潜在的なセキュリティ脅威を軽減するために、予測可能性を低下させる目的で、返される値をある量で丸めることを覚えておくことが重要です。これは、タイマーの解像度や精度を制限することで、意図的にある程度不正確にします。例えば、 Firefox は返される時刻を 1 ミリ秒単位で丸めます。 -

構文

+返される値の精度は、セキュリティ上の懸念が他の手段で軽減された場合、またはされた場合に変更される可能性があります。 -
t = performance.now();
+## 構文 -

+```js +t = performance.now(); +``` -
var t0 = performance.now();
+## 例
+
+```js
+const t0 = performance.now();
 doSomething();
-var t1 = performance.now();
-console.log("Call to doSomething took " + (t1 - t0) + " milliseconds.");
-
+const t1 = performance.now(); +console.log(`Call to doSomething took ${t1 - t0} milliseconds.`); +``` -

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

+JavaScript で利用できる他の時刻のデータ(例えば [`Date.now`](/ja/docs/Web/JavaScript/Reference/Global_Objects/Date/now))とは異なり、 `performance.now()` が返すタイムスタンプは、 1 ミリ秒の分解能に制限されません。代わりに、マイクロ秒までの精度を持った浮動小数点の値で時刻を表します。 -

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

+また、`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 (ミリ秒) になります。

+タイミング攻撃やフィンガープリンティングから保護するため、ブラウザーの設定によっては、 `performance.now()` の精度が丸められることがあります。 +Firefox では、 `privacy.reduceTimerPrecision` の設定が既定で有効になっており、既定で 1 ミリ秒となっています。 -
// Firefox 60 での時間精度の引き下げ (2ms)
+```js
+// Firefox 60 での時間精度の引き下げ (1ms)
 performance.now();
 // 8781416
-// 8781814
+// 8781815
 // 8782206
 // ...
 
-
 // `privacy.resistFingerprinting` 有効化による時間精度の引き下げ`
 performance.now();
 // 8865400
 // 8866200
 // 8866700
 // ...
-
+``` + +Firefox では `privacy.resistFingerprinting` も有効にすることができます。これは、精度を 100 ミリ秒または `privacy.resistFingerprinting.reduceTimerPrecision.microseconds` のどちらか大きい方へ変更します。 + +Firefox 79 以降では、高精度タイマーは文書が {{HTTPHeader("Cross-Origin-Opener-Policy")}} および {{HTTPHeader("Cross-Origin-Embedder-Policy")}} ヘッダーを使用してクロスオリジン分離を行っている場合に使用することができるようになりました。 + +```plain +Cross-Origin-Opener-Policy: same-origin +Cross-Origin-Embedder-Policy: require-corp +``` -

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

+これらのヘッダーは、最上位の文書がクロスオリジン文書と閲覧コンテキストグループを共有しないことを保証します。 COOP プロセスは、文書を分離し、潜在的な攻撃者がポップアップでそれを開いていたとしても、グローバルオブジェクトにアクセスできないようにし、 [XS-Leaks](https://github.com/xsleaks/xsleaks) と呼ばれる一連のクロスオリジン攻撃を防止しています。

仕様

@@ -89,15 +100,14 @@ performance.now(); -

ブラウザー実装状況

+## 仕様書 +{{Specifications}} +## ブラウザーの互換性 -

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

+{{Compat}} -

関連情報

+## 関連情報 - +- [When milliseconds are not enough: performance.now()](http://updates.html5rocks.com/2012/08/When-milliseconds-are-not-enough-performance-now) (HTML5 Rocks) -- cgit v1.2.3-54-g00ecf