《iOS和macOS性能优化读书笔记之一》

一、CPU原理

  • OC是一种混编语言,如果你在计算过程中采用基本的类型比如int, double等计算时间非常小,比Swift,Java采用基本数据类型计算还小。如果是采用OC的类型,比如NSNumber等,就会比较耗时。
  • OC在快速创建对象时,比其他纯粹的面向对象的语言要慢。
  • 复杂度计算,通过indexOfObject实现的隐式二次算法的例子,如果传入参数是一个数组,使用indexOfObject方法执行检查时,执行次数为O(m),如果该成NSSet,已经摊销了 O(1)用于检查存在。

二、测量和工具

  • top 在命令行输入:top -u 命令

  • time 命令

  • sample 命令,配合top命令和time命令查看具体信息

  • Xcode测量工具:打开Xcode主窗口左侧的调试导航器(command+7)

  • Instrument:作为一个功能强大的采样工具,它的输出信息通常是指示性的不是定性的。

  • instrument 设置和收集数据:Xcode->Production->Profile->Time Profile启动时间分析工具。点击file->RecordingOption->Time Limited 设置检测时间限制

  • instrument 基本分析:详细信息视图中的每一行显示单个函数或方法,对于每个函数,显示当前函数和子函数的总运行时间(以毫秒为单位)。小图标表示函数的来源,头像表示用户ÿ

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
iOS and Macos Performance Tuning: Cocoa, Cocoa Touch, Objective-C, and Swift (Developer's Library) by Marcel Weiher English | 3 Mar. 2017 | ISBN: 0321842847 | 400 Pages | EPUB/PDF (conv) | 42.64 MB In iOS and macOS™ Performance Tuning, Marcel Weiher drills down to the code level to help you systematically optimize CPU, memory, I/O, graphics, and program responsiveness in any Objective-C, Cocoa, or CocoaTouch program. This up-to-date guide focuses entirely on performance optimization for macOS and iOS. Drawing on 25 years of experience optimizing Apple device software, Weiher identifies concrete performance problems that can be discovered empirically via measurement. Then, based on a deep understanding of fundamental principles, he presents specific techniques for solving them. Weiher presents insights you won’t find anywhere else, most of them applying to both macOS and iOS development. Throughout, he reveals common pitfalls and misconceptions about Apple device performance, explains the realities, and helps you reflect those realities in code that performs beautifully. Understand optimization principles, measurement, tools, pitfalls, and techniques Recognize when to carefully optimize, and when it isn’t worth your time Balance performance and encapsulation to create efficient object representations, communication, data access, and computation Avoid mistakes that slow down Objective-C programs and hinder later optimization Fix leaks and other problems with memory and resource management Address I/O issues associated with drives, networking, serialization, and SQLite Code graphics and UIs that don’t overwhelm limited iOS device resources Learn what all developers need to know about Swift performance

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值