View in English

  • Apple 开发者
    • 入门汇总

    探索“入门汇总”

    • 概览
    • 学习
    • Apple Developer Program

    及时了解最新动态

    • 最新动态
    • 开发者你好
    • 平台

    探索“平台”

    • Apple 平台
    • iOS
    • iPadOS
    • macOS
    • Apple tvOS
    • visionOS
    • watchOS
    • App Store

    精选

    • 设计
    • 分发
    • 游戏
    • 配件
    • 网页
    • Home
    • CarPlay 车载
    • 技术

    探索“技术”

    • 概览
    • Xcode
    • Swift
    • SwiftUI

    精选

    • 辅助功能
    • App Intents
    • Apple 智能
    • 游戏
    • 机器学习与 AI
    • 安全性
    • Xcode Cloud
    • 社区

    探索“社区”

    • 概览
    • “与 Apple 会面交流”活动
    • 社区主导的活动
    • 开发者论坛
    • 开源

    精选

    • WWDC
    • Swift Student Challenge
    • 开发者故事
    • App Store 大奖
    • Apple 设计大奖
    • Apple Developer Centers
    • 文档

    探索“文档”

    • 文档库
    • 技术概述
    • 示例代码
    • 《人机界面指南》
    • 视频

    发布说明

    • 精选更新
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • Apple tvOS
    • Xcode
    • 下载

    探索“下载”

    • 所有下载
    • 操作系统
    • 应用程序
    • 设计资源

    精选

    • Xcode
    • TestFlight
    • 字体
    • SF Symbols
    • Icon Composer
    • 支持

    探索“支持”

    • 概览
    • 帮助指南
    • 开发者论坛
    • “反馈助理”
    • 联系我们

    精选

    • 《开发者账户帮助》
    • 《App 审核指南》
    • 《App Store Connect 帮助》
    • 即将实行的要求
    • 协议和准则
    • 系统状态
  • 快速链接

    • 活动
    • 新闻
    • 论坛
    • 示例代码
    • 视频
 

视频

打开菜单 关闭菜单
  • 专题
  • 所有视频
  • 关于

更多视频

  • 简介
  • 概要
  • 代码
  • 查找并修复 Metal 游戏中的性能问题

    使用强大的 Metal 工具追踪难以发现的游戏性能问题。了解如何通过 Instruments 中的 Game Performance Overview 收集丰富的性能数据,在 macOS 和 iOS 上分别利用 metalperftrace 和控制中心来运行后台性能追踪,并使用全新的 StateReporting API 将指标直接关联到游戏的运行时状态。将数小时的遥测数据转化为清晰明确、切实可行的见解。

    章节

    • 0:00 - Introduction
    • 1:51 - Metal performance metrics
    • 3:32 - Trace collection
    • 6:38 - Analyze performance traces
    • 10:08 - Contextualize with StateReporting
    • 17:48 - Collect field data with MetricKit
    • 19:41 - Next steps

    资源

    • Understanding the Metal Performance HUD metrics
    • Monitoring your Metal app’s graphics performance
    • Getting started with StateReporting
    • Metal debugger
      • 高清视频
      • 标清视频

    相关视频

    Tech Talks

    • 探索适用于 M3 和 A17 Pro 的新 Metal 性能剖析工具
  • 搜索此视频…
    • 5:00 - Collect a trace with metalperftrace

      # Collect the last 5 hours
      metalperftrace collect /tmp --last 5h
      
      # Output
      # Metal performance traces collected to: /tmp
      # /tmp/MetalPerfTrace_20260401_094100_to_144100.atrc
      
      # Or collect an explicit time range
      metalperftrace collect /tmp \
        --start 2026-04-01T09:41:00 \
        --end 2026-04-01T12:41:00
    • 7:02 - Print a trace overview

      metalperftrace overview /Data/MyGameTrace.atrc
      
      # [Modern Renderer pid:13833]
      # Mem: 2146.1 MiB (2343.9 Peak, 1199.4 Metal)
      # Total CPU Time: 2417.601s (33.17% Sys, 66.83% User)
      # Instructions: 9944836683668 (5.75% P, 94.25% E)
      # Cycles: 5176430469224 (4.45% P, 95.55% E)
      # Disk Reads / Writes: 317.37 / 0.04 MiB (Logical Write 0.04)
      # Layer 0x729293000 (3456x2104) Interval 300.065s Active 300.065s
      #   59.7 FPS  17735 Frames  188 Skipped
      #   Frame Time avg: 16.74ms min: 8.33 max: 125.00 stddev: 3.70
      #   CPU Begin-to-Present avg: 3.99ms min: 1.40 max: 94.37 stddev: 1.80
      #   On-GPU Time avg: 13.39ms min: 5.24 max: 37.57 stddev: 1.43
      #   Next Drawable Wait avg: 0.26ms min: 0.00 max: 91.08 stddev: 1.75
      #   Shader Compilation Time: 0.000s (Total: 0, Cached: 18)
    • 7:58 - Filter by process and emit JSON

      // Report state transitions
      #import <StateReporting/StateReporting.h>
      
      NSString *domain = @"com.mygame.level";
      SRStateReporter *reporter = [SRStateReporter reporterForDomain:domain];
      
      [reporter reportTransitionToStateLabel:@"Level 1"
                              stableMetadata:nil
                            volatileMetadata:nil];
      
      [reporter reportTransitionToStateLabel:@"Level 1"
                              stableMetadata:@{ @"id": @1001 }
                            volatileMetadata:nil];
      
      [reporter reportVolatileMetadataUpdate:@{ @"health": @100 }];
    • 13:55 - Include full state transitions in overview

      metalperftrace overview /Data/MyGameTrace.atrc --include-state-transitions
      
      # [States]
      # com.mygame.graphics
      #   High (30.59%, 14.996s)  raytracing: 1  shadow: ultra
      #   Medium (69.38%, 34.012s)  raytracing: 0  shadow: medium
      # com.mygame.level
      #   Level 1 (20.47%, 10.033s)  biome: forest   id: 1001
      #   Level 2 (79.53%, 38.991s)  biome: volcano  id: 1002
    • 14:15 - Aggregate metrics by state

      # Aggregate across all domains / transitions
      metalperftrace overview /Data/MyGameTrace.atrc --aggregate
      
      # Aggregate one domain
      metalperftrace overview /Data/MyGameTrace.atrc --aggregate \
        --domain com.mygame.graphics
      
      # Aggregate a specific state label within a domain
      metalperftrace overview /Data/MyGameTrace.atrc --aggregate \
        --domain com.mygame.graphics \
        --state-label "High"
    • 0:00 - Introduction
    • Overview of the challenge of maintaining consistent frame rates in games across long play sessions, and a preview of the new tools and workflows for collecting, analyzing, and contextualizing Metal performance data.

    • 1:51 - Metal performance metrics
    • A tour of the Metal performance metrics available through tools like the Metal Performance HUD, covering FPS, GPU time, frame interval, layer sizes, composition mode, and MetalFX-related metrics.

    • 3:32 - Trace collection
    • How to collect performance traces using the Game Performance Overview template in Instruments for desk testing, and the new always-on system-level data collection on iOS and macOS that stores Metal performance metrics for days.

    • 6:38 - Analyze performance traces
    • How to analyze collected traces using the metalperftrace command-line tool on macOS — printing overviews, exporting JSON for scripting or AI agents — and how to open and visualize traces in Instruments to identify FPS drops and other anomalies.

    • 10:08 - Contextualize with StateReporting
    • Introduces the StateReporting API, which lets you describe your game's behavior and state over time using domains, states, and metadata. Learn how state transitions appear in the Metal Performance HUD, metalperftrace output, and Instruments tracks to make performance issues immediately actionable.

    • 17:48 - Collect field data with MetricKit
    • How to use MetricKit in macOS and iOS 27 to collect Metal frame rate data and other performance metrics in the field after your game ships, including per-state breakdowns using StateReporting domains.

    • 19:41 - Next steps
    • Key takeaways and recommended next steps: adopt StateReporting, try the new trace collection tools and metalperftrace CLI, and explore related Metal developer tools documentation.

Developer Footer

  • 视频
  • WWDC26
  • 查找并修复 Metal 游戏中的性能问题
  • 打开菜单 关闭菜单
    • iOS
    • iPadOS
    • macOS
    • Apple tvOS
    • visionOS
    • watchOS
    打开菜单 关闭菜单
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • SF Symbols
    打开菜单 关闭菜单
    • 辅助功能
    • 配件
    • Apple 智能
    • App 扩展
    • App Store
    • 音频与视频 (英文)
    • 增强现实
    • 设计
    • 分发
    • 教育
    • 字体 (英文)
    • 游戏
    • 健康与健身
    • App 内购买项目
    • 本地化
    • 地图与位置
    • 机器学习与 AI
    • 开源资源 (英文)
    • 安全性
    • Safari 浏览器与网页 (英文)
    打开菜单 关闭菜单
    • 完整文档 (英文)
    • 部分主题文档 (简体中文)
    • 教程
    • 下载
    • 论坛 (英文)
    • 视频
    打开菜单 关闭菜单
    • 支持文档
    • 联系我们
    • 错误报告
    • 系统状态 (英文)
    打开菜单 关闭菜单
    • Apple 开发者
    • App Store Connect
    • 证书、标识符和描述文件 (英文)
    • 反馈助理
    打开菜单 关闭菜单
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program (英文)
    • Mini Apps Partner Program
    • News Partner Program (英文)
    • Video Partner Program (英文)
    • 安全赏金计划 (英文)
    • Security Research Device Program (英文)
    打开菜单 关闭菜单
    • 与 Apple 会面交流
    • Apple Developer Center
    • App Store 大奖 (英文)
    • Apple 设计大奖
    • Apple Developer Academies (英文)
    • WWDC
    阅读最近新闻。
    获取 Apple Developer App。
    版权所有 © 2026 Apple Inc. 保留所有权利。
    使用条款 隐私政策 协议和准则