flags | 控制行为的标志,包括读取后清除底层已完成指标。 |
AsyncReadManagerSummaryMetrics 当前指标数据的摘要。
获取自您开始数据收集或上次清除指标数据以来为 AsyncReadManager 读取操作收集的指标摘要。
返回的 AsyncReadManagerSummaryMetrics 对象提供了有关收集数据的总体统计信息。调用 GetMetrics 以获取用于摘要的底层指标数据。
将 flags
参数设置为在返回摘要后清除所有数据。这与调用 ClearCompletedMetrics 具有相同的效果。
using Unity.IO.LowLevel.Unsafe; using UnityEngine; public class AsyncReadManagerMetricsSample : MonoBehaviour { #if ENABLE_PROFILER && UNITY_2020_2_OR_NEWER void Start() { AsyncReadManagerMetrics.StartCollectingMetrics(); }
void Update() { if (Time.frameCount == 10) { AsyncReadManagerSummaryMetrics summaryOfMetrics = AsyncReadManagerMetrics.GetCurrentSummaryMetrics(AsyncReadManagerMetrics.Flags.ClearOnRead); Debug.LogFormat($"Average bandwidth of every read over 10 frames: {summaryOfMetrics.AverageBandwidthMBPerSecond}MB/s"); Debug.LogFormat($"Number of completed reads in 10 frames: {summaryOfMetrics.NumberOfCompletedRequests}"); Debug.LogFormat($"Total number of requests in 10 frames: {summaryOfMetrics.TotalNumberOfRequests}"); Debug.LogFormat($"Subsystem responsible for longest file read: {summaryOfMetrics.LongestReadSubsystem}"); Debug.LogFormat($"Asset type responsible for longest wait: {summaryOfMetrics.LongestWaitAssetType}"); } }
#endif }
metricsFilters | 在计算摘要之前应用于指标的过滤器。 |
flags | 控制行为的标志,包括读取后清除底层已完成指标。 |
AsyncReadManagerSummaryMetrics 当前指标数据的摘要,由指定的 metricsFilters
过滤。
获取自您开始数据收集或上次清除指标数据以来为 AsyncReadManager 读取操作收集的过滤指标摘要。
此函数过滤为 AsyncReadManager 读取操作收集的指标,并根据过滤后的数据提供摘要。有关过滤器创建的信息,请参见 AsyncReadManagerMetricsFilters.ctor。
using Unity.IO.LowLevel.Unsafe; using UnityEngine;
public class AsyncReadManagerMetricsSample : MonoBehaviour { #if ENABLE_PROFILER && UNITY_2020_2_OR_NEWER AsyncReadManagerMetricsFilters filters; void Start() { AsyncReadManagerMetrics.StartCollectingMetrics(); filters = new AsyncReadManagerMetricsFilters(); filters.SetPriorityFilter(Priority.PriorityHigh); filters.SetSubsystemFilter(AssetLoadingSubsystem.Texture); }
void Update() { AsyncReadManagerSummaryMetrics filteredSummaryOfMetrics = AsyncReadManagerMetrics.GetCurrentSummaryMetrics(filters, AsyncReadManagerMetrics.Flags.None); Debug.LogFormat($"Number of requests matching given filters: {filteredSummaryOfMetrics.TotalNumberOfRequests}"); Debug.LogFormat($"Average bandwidth for textures in high priority queue: {filteredSummaryOfMetrics.AverageBandwidthMBPerSecond}MB/s"); // Clear completed reads from metrics each frame to avoid rereading the same requests AsyncReadManagerMetrics.ClearCompletedMetrics(); }
#endif }