返回上级目录: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的使用相关推荐

  1. Mac/IOS Xcode Instruments资源统计及自动化相关

    一.遇到的问题 (1)Instruments启动采集某个应用的资源时,提示"Instruments wants permission to analyze other processes.  ...

  2. iOS 使用Instruments优化内存性能

    iOS 使用Instruments优化内存性能 问题 项目中使用到图片合成视频,发现内存增长十分的迅速,导致一些因为内存引起的问题,本文使用这个案例,结合Instruments工具检测和分析问题,最终 ...

  3. ios xcode真机调试获取屏幕截屏

    ios xcode真机调试获取屏幕截屏 非常多时候我们须要在调试的过程中把手机屏幕截图发给其它人看,在android开发中我们能够非常方便的截图保存.而xcode开发ios的时候发现这个需求却如此困难 ...

  4. [转]phonegap 2.9 IOS Xcode 搭建环境

    phonegap 2.9 IOS Xcode 搭建环境 一:下载phoneGap2.9和安装Xcode5(目前最新版) 选择2.9是因为3.0以上坑爹版本编译神马的要在有网络情况. 二: 下载phon ...

  5. iOS XCode 解决 Showing Recent Messages :-1: Unable to load contents of file list

    iOS XCode 解决 Showing Recent Messages

  6. 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 ...

  7. 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' ...

  8. iOS性能分析-Xcode Instruments Allocations 分析APP内存使用情况

    All Heap & Anonymous VM 堆内存+虚拟内存 All Heap Allocations 堆内存 All Anonymous VM 虚拟内存 # Persistent 表示在 ...

  9. [xcode]instruments来检验你的app

    原文网址:http://www.cocoachina.com/industry/20140114/7696.html 比较了好多关于instruments 还是发现老外写的比较牛逼.于是果断翻译过来. ...

最新文章

  1. 开放应用模型操作指南(一)| 云服务一键接入 OAM 体系
  2. 如何使用autotools工具
  3. go标准库的学习-encoding/json
  4. 开源资产管理系统_部署开源夜莺运维监控平台V3版本
  5. 智能家居火了这么久 何时到我家?
  6. SCI论文编辑教你如何准备SCI论文和写作
  7. 非常实用的面试题,也可以当作学习资料(转载)
  8. iPad 读不到 USB,在 Mac 上如何进行 USB 格式化?
  9. python导出excel 身份证_如何使用Python导出Excel文件?
  10. sidirect 连接西门子_Intouch 与 CP343-1 通讯设置
  11. 红番茄(VS2017)两个注意点
  12. vfp mysql教程_VFP基础教程 5.5 编辑框控件(editbox)
  13. 如何用定积分求椭圆的周长_怎么用微积分求椭圆的周长?
  14. python---合并两个excel表格内容
  15. 用计算机弹EXO简谱,Power钢琴简谱-数字双手-EXO
  16. 快递鸟 物流跟踪订阅 即时查询快递 预约取件(在线下单)
  17. linux服务器实训心得体会,linux实训心得体会
  18. 网上看到的星际制图技巧,有些反作弊的方法还是可以借鉴的
  19. mybatis操作Oracle数据库批量插入与更新、运行注意事项、属性含义
  20. vue JsBarcode 常用参数设置

热门文章

  1. 《光之圣境放置次元》1.26上线链游玩家|放置挂机、重塑神域
  2. 机器人导航技术的研究现状和发展趋势
  3. 数据结构 C 代码 6.2: 哈夫曼树 (学生提供代码)
  4. 如何通过QA质量管理提高软件质量?
  5. 基于单片机超声波控制电机转动系统设计
  6. SQL优化不会?推荐4 款工具
  7. 【Matlab系列】MATLAB中显示输出数据的四种方式
  8. 国际网页短信软件平台后台功能篇|移讯云短信系统开发
  9. 软件开发方法和开发模型的比较
  10. js实现简单好玩儿的放大镜个人讲解