API リファレンス
myaku(options?)
プロファイリングを開始して Profiler を返します。すでに動いているもの(window.__MYAKU__)があれば、それを返します。
| オプション | デフォルト | |
|---|---|---|
size | 600 | 保持するフレーム数 |
budgetMs | ディスプレイのフレーム間隔の 1.5 倍 | これより遅いフレームがヒッチになります |
contexts | true | canvas コンテキスト上の描画、アップロード、コンパイルを数えます |
global | true | window.__MYAKU__ として公開します |
engines | true | エンジンのスパンを自動で追加します(詳細) |
import "myaku/auto"
プロファイラーを開始し、オーバーレイを表示します。
Profiler
report() | バッファ内のフレームについての Report |
hitches() | バッファ内の遅いフレームすべてを Verdict として、古い順に |
explain(ago = 0) | 1 フレーム分の Verdict(0 = 最新) |
frame(ago = 0)、frames(count?) | 生の Frame |
span(name, fn) | fn を name で計測し、fn の戻り値を返します |
begin(name) | スパンを開始します。返された関数を呼ぶと終了します |
addSpan(name, ms) | 計測済みの時間をスパンに加えます |
subscribe(fn) | 毎フレームのあとに fn を呼びます。購読解除の関数を返します |
stop() | Myaku がラップしたものをすべて元に戻します |
budgetMs、displayIntervalMs、overheadMs、length、size、support | プロパティ |
adapt(profiler, game)
Phaser の Game、PixiJS の Application、three.js のレンダラーにエンジンのスパンを追加します。"phaser"、"pixi"、"three"、または undefined を返します。
overlay(profiler, options?)
隅のグラフを表示します。オプションは corner(デフォルトは "top-right")と parent です。{ element, toggle(visible?), destroy() } を返します。
Frame
index、at、intervalMs、cpuMs、draws、uploads、uploadBytes、compiles、heapDropBytes、spans。
Verdict
frame、at、intervalMs、budgetMs、cause、confidence、summary、hint、where?(source、fn、line?、char)、evidence。判定の読み方も参照してください。
Report
frames、seconds、fps、budgetMs、displayIntervalMs、intervalMs(p50、p95、p99、max)、cpuMs(p50、p95、max)、hitches、hitchesPerMinute、causes、worst、spans、perFrame、overheadMs、support。レポートも参照してください。