Getting Started with Instruments
開始使用 Instruments
Xcode 中的 Instruments 應用程式提供了一套豐富的工具和範本,用於分析您的應用程式性能。了解所有有關 Instruments 的資訊,並獲得識別代碼瓶頸的策略。看看如何利用時間分析和興趣點追蹤的力量,對您的代碼進行有意義的更改,從而顯著改善應用程式的響應能力。
Time Profiler 時間分析器
uses infrastructure provided by the operating system to collect call stacks of relevant threads at a fixed interval.
使用操作系統提供的基礎設施,在固定的時間間隔內收集相關線程的調用堆棧。
Points of Interest 興趣點
collects data from important areas of the app that we can highlight using various APIs such as Signpost API.
從應用程式的重要區域收集數據,我們可以使用各種 API 來突出顯示,例如 Signpost API。
Time Profile Template 時間配置模板
This template is used to profile both time and POI
此模板用於分析時間和 POIlets us add even more instruments to get more insights on the app.
讓我們添加更多工具,以獲得有關應用程式的更多見解。great tool for looking at issues that occur over a particular window of time. 
很棒的工具,用於查看在特定時間範圍內發生的問題。
Track Viewer 追蹤檢視器
A Track shows time series trace data corresponding to one source of events, such as the process, thread, or CPU core.
一個追蹤顯示與一個事件來源相對應的時間序列追蹤數據,例如進程、線程或 CPU 核心。A single Instrument may contribute trace data to multiple Tracks.
單一儀器可以將追蹤數據貢獻給多個軌道。The top Track is a summary of our application’s CPU utilization provided by the Time Profiler Instrument.
頂部的追蹤是由時間分析工具提供的我們應用程式 CPU 使用率的摘要。Spinning is how Instruments refers to your main thread being blocked:
旋轉是 Instruments 用來指您的主執行緒被阻塞的方式:
Details View 詳細檢視
allows to explore the trace data for the selected Track.
允許探索所選追蹤的追蹤數據。when a time profiler trace is selected, it shows us a call graph: these are all the functions that were invoked during the time of the profile.
當選擇時間分析器追蹤時,它會顯示我們一個調用圖:這些是分析期間被調用的所有函數。
Detail inspector 詳細檢查器
When exploring the detail inspector (right column), we can click on a closure row to see it selected in the Detail view:
當探索詳細檢查器(右側欄位)時,我們可以點擊一個閉包行以在詳細視圖中查看其被選中Double clicking the closure in the inspector jumps right into the line of code in the source.
在檢查器中雙擊閉包會直接跳轉到源代碼中的那一行。
Profiling tips 性能分析技巧
If you have response issues, check the main thread in the time profile.
如果您有回應問題,請檢查時間配置檔中的主要線程。profile in release mode 在釋出模式下的配置
Using Signposts 使用指示牌
More performant the print statements and the likes
更高效的打印語句及類似內容Natively supported by Instruments
原生支援 InstrumentsHas its own dedicated trace: Point of interestsThe POI trace shows a region of interest that corresponds to a Signpost interval that I added to my code.
擁有自己的專用追蹤:興趣點 POI 追蹤顯示了一個與我添加到代碼中的指示牌間隔相對應的興趣區域。
Profile Tests 個人資料測試
Written By 撰寫者
Federico Zanetello 費德里科·扎內泰洛
Contributed Notes | GitHub | Blog
貢獻的註解 | GitHub | 部落格
Missing anything? Corrections? Contributions are welcome!
有遺漏嗎?有修正嗎?歡迎貢獻!
Related Sessions 相關會議
使用 Instruments 分析掛起問題
用戶界面元素通常模仿現實世界的互動,包括即時反應。用戶互動中有明顯延遲的應用程式——即卡頓——會打破這種幻覺並造成挫折。我們將向您展示如何使用 Instruments 來分析、理解和修復您在所有 Apple 平台上的應用程式中的卡頓。了解如何有效地導航 Instruments 跟蹤文檔、解釋跟蹤數據,並記錄額外的性能數據,以更好地理解您的特定卡頓。
優化您對 Core Data 和 CloudKit 的使用
加入我們,探索開發週期的三個部分,幫助您優化 Core Data 和 CloudKit 的實現。我們將向您展示如何分析應用程式的架構和功能集,以驗證假設,探索在處理大型數據集後行為的變化,並獲得可行的反饋,以改善您的工作流程。
檢測和診斷記憶體問題
了解如何使用 Xcode 理解和診斷記憶體性能問題。我們將帶您了解 Xcode 工具的最新更新,探索指標,查看 XCTest 中的 memgraph 收集功能,並學習如何使用 Performance XCTest 捕捉回歸問題。
終極應用程式性能生存指南
性能優化可能看起來是一項艱鉅的任務——需要追蹤許多指標和使用多種工具。別擔心:我們的應用性能生存指南在此幫助您了解工具、指標和範式,這些都能幫助您順利開發過程,並為使用您應用的人提供良好的體驗。
更快獲得測試結果
改善您的測試套件,以加快反饋循環並更快獲得修復。了解有關 Xcode 中測試的最新改進,包括如何利用測試計劃、Xcodebuild 更新和 API 來消除無休止和行為不當的測試。我們將探討 XCTest 中的測試超時和執行時間允許,檢查設備並行化,並詳細說明在性能與清晰故障定位之間取得平衡的建議做法。
Xcode 11 的新功能
以 Xcode 11 的新功能巡禮開始這一週,旨在幫助您比以往更快地從想法轉變為產品。探索編輯和組織源代碼的新方法、設計和預覽用戶界面的新功能,以及調試和測試的重大改進。獲取今年涵蓋開發者工具的會議概覽。
Legal Notice 法律聲明
All content copyright © 2012 – 2024 Apple Inc. All rights reserved. Swift, the Swift logo, Swift Playgrounds, Xcode, Instruments, Cocoa Touch, Touch ID, FaceID, iPhone, iPad, Safari, Apple Vision, Apple Watch, App Store, iPadOS, watchOS, visionOS, tvOS, Mac, and macOS are trademarks of Apple Inc., registered in the U.S. and other countries. This website is not made by, affiliated with, nor endorsed by Apple.
所有內容版權 © 2012 – 2024 蘋果公司。保留所有權利。Swift、Swift 標誌、Swift Playgrounds、Xcode、Instruments、Cocoa Touch、Touch ID、FaceID、iPhone、iPad、Safari、Apple Vision、Apple Watch、App Store、iPadOS、watchOS、visionOS、tvOS、Mac 和 macOS 是蘋果公司的商標,在美國及其他國家註冊。本網站並非由蘋果公司製作、與其關聯或獲得其認可。