iOS:Xcode Instruments的使用
返回上级目录:iOS 性能优化(一):Improving Your App‘s Performance
文章目录
- 1.使用实例
- 1.1 Points of Inerest(标记代码执行的点和执行时间)
- 1.1.1 oc版,+load方法
- override class func load()在swift中不被允许
- instruments测试截图:+load方法的执行在启动的Initializing - Static Runtime Initialization阶段
- 代码:用swift代码通过桥接文件来实现
- 1.1.2 我2022.3.1日打印出来感觉很不对,如下图
- 2.苹果官网资料
- 3.实际操作
- 3.1 时间段左右上下放大缩小
1.使用实例
1.1 Points of Inerest(标记代码执行的点和执行时间)
import MetricKitclass ViewController: UIViewController {static let startupActivities:StaticString = "viewDidLoad"let poiLog = OSLog(subsystem: "com.example.CocoaPictures", category: .pointsOfInterest)override func viewDidLoad() {super.viewDidLoad()os_signpost(.begin, log: self.poiLog, name: ViewController.startupActivities)for i in 0...100 {print(i)}os_signpost(.end, log: self.poiLog, name: ViewController.startupActivities)
代码出处:
Apple Developer: Reducing Your App’s Launch Time
1.1.1 oc版,+load方法
override class func load()在swift中不被允许
instruments测试截图:+load方法的执行在启动的Initializing - Static Runtime Initialization阶段
代码:用swift代码通过桥接文件来实现
import UIKit
import MetricKitclass XXYMetric: NSObject {static var startupActivities:StaticString = "didFinishLaunching"static var poiLog = OSLog(subsystem: "com.example.CocoaPictures", category: .pointsOfInterest)@objc class func start(str: String) {poiLog = OSLog(subsystem: str, category: .pointsOfInterest)os_signpost(.begin, log: poiLog, name: startupActivities)}@objc class func end(str: String) {poiLog = OSLog(subsystem: str, category: .pointsOfInterest)os_signpost(.end, log: poiLog, name: startupActivities)}}
#import "XXYPerson.h"
#import "XCTEST_oc-Swift.h"@implementation XXYPerson+ (void)load {[XXYMetric startWithStr:@"load"];for (int i = 0; i < 1000; i++) {NSLog(@"%d",i);}[XXYMetric endWithStr:@"load"];}@end
1.1.2 我2022.3.1日打印出来感觉很不对,如下图
- viewDidLoad方法怎么会和viewWillAppear方法同时执行?
- 打印十个数字怎么要4.8s?
2.苹果官网资料
WWDC视频:
WWDC2019:Developing a Great Profiling Experience
WWDC2019:Modeling in Custom Instruments
WWDC2019: Getting Started with Instruments
苹果官方文档:
Apple Developer: Instruments Help
参考博客:
Xcode Instruments的使用
iOS -调试工具Instruments使用总结
3.实际操作
3.1 时间段左右上下放大缩小
Ctrl + Ctrl - 是上下的变大变小
iOS:Xcode Instruments的使用相关推荐
- Mac/IOS Xcode Instruments资源统计及自动化相关
一.遇到的问题 (1)Instruments启动采集某个应用的资源时,提示"Instruments wants permission to analyze other processes. ...
- iOS 使用Instruments优化内存性能
iOS 使用Instruments优化内存性能 问题 项目中使用到图片合成视频,发现内存增长十分的迅速,导致一些因为内存引起的问题,本文使用这个案例,结合Instruments工具检测和分析问题,最终 ...
- ios xcode真机调试获取屏幕截屏
ios xcode真机调试获取屏幕截屏 非常多时候我们须要在调试的过程中把手机屏幕截图发给其它人看,在android开发中我们能够非常方便的截图保存.而xcode开发ios的时候发现这个需求却如此困难 ...
- [转]phonegap 2.9 IOS Xcode 搭建环境
phonegap 2.9 IOS Xcode 搭建环境 一:下载phoneGap2.9和安装Xcode5(目前最新版) 选择2.9是因为3.0以上坑爹版本编译神马的要在有网络情况. 二: 下载phon ...
- iOS XCode 解决 Showing Recent Messages :-1: Unable to load contents of file list
iOS XCode 解决 Showing Recent Messages
- iOS/Xcode异常:no visible @interface for XXX declares the selector YYY
iOS/Xcode异常:no visible @interface for XXX declares the selector YYY 参考文章: (1)iOS/Xcode异常:no visible ...
- iOS Xcode 中类文件后面标记A、D、M、R、C、?、! 等含义 'A' 新增 'D' 删除 'M' 修改 'R' 替代 'C'
//联系人:石虎 QQ:1224614774 昵称:嗡嘛呢叭咪哄 一.概念 iOS Xcode 中类文件后面标记A.D.M.R.C.?.!等含义 'A' 新增 'D' 删除 'M' 修改 'R' ...
- iOS性能分析-Xcode Instruments Allocations 分析APP内存使用情况
All Heap & Anonymous VM 堆内存+虚拟内存 All Heap Allocations 堆内存 All Anonymous VM 虚拟内存 # Persistent 表示在 ...
- [xcode]instruments来检验你的app
原文网址:http://www.cocoachina.com/industry/20140114/7696.html 比较了好多关于instruments 还是发现老外写的比较牛逼.于是果断翻译过来. ...
最新文章
- 开放应用模型操作指南(一)| 云服务一键接入 OAM 体系
- 如何使用autotools工具
- go标准库的学习-encoding/json
- 开源资产管理系统_部署开源夜莺运维监控平台V3版本
- 智能家居火了这么久 何时到我家?
- SCI论文编辑教你如何准备SCI论文和写作
- 非常实用的面试题,也可以当作学习资料(转载)
- iPad 读不到 USB,在 Mac 上如何进行 USB 格式化?
- python导出excel 身份证_如何使用Python导出Excel文件?
- sidirect 连接西门子_Intouch 与 CP343-1 通讯设置
- 红番茄(VS2017)两个注意点
- vfp mysql教程_VFP基础教程 5.5 编辑框控件(editbox)
- 如何用定积分求椭圆的周长_怎么用微积分求椭圆的周长?
- python---合并两个excel表格内容
- 用计算机弹EXO简谱,Power钢琴简谱-数字双手-EXO
- 快递鸟 物流跟踪订阅 即时查询快递 预约取件(在线下单)
- linux服务器实训心得体会,linux实训心得体会
- 网上看到的星际制图技巧,有些反作弊的方法还是可以借鉴的
- mybatis操作Oracle数据库批量插入与更新、运行注意事项、属性含义
- vue JsBarcode 常用参数设置