リポジトリ
使用例
using System.IO; using System.Threading.Tasks; using Kogane.CompleteEventsTracer; using UnityEngine; public sealed class Example : MonoBehaviour { private async void Start() { Debug.Log( "開始" ); var tracer = new CompleteEventsTracer(); async Task Process( string name, float duration ) { using ( tracer.Start( name ) ) { await Task.Delay( ( int ) ( duration * 1000 ) ); } } await Process( "A", 0.1f ); await Process( "B", 0.2f ); await Process( "C", 0.3f ); await Task.WhenAll ( Process( "D", 0.3f ), Process( "E", 0.2f ), Process( "F", 0.1f ) ); await Process( "G", 0.1f ); var json = tracer.ToJson(); await File.WriteAllTextAsync( "result.json", json ); Debug.Log( "完了" ); } }
たとえば上記のように CompleteEventsTracer クラスを使用して処理時間を計測し、
その結果を JSON で result.json に出力します
Chrome のアドレスバーに chrome://tracing
と入力して
表示されたページで「Load」を押して出力した result.json を選択します
これで計測した処理時間を Chrome 上でプロファイリングできます