iOS和macOS性能最佳化:Cocoa,Cocoa Touch,Objective-C和Swift书籍信息着 者:(德)Marcel Weiher(马塞尔·韦伊尔)作 译 者:李俊阳等出版时间:2018-06 千 字 数:442版 次:01-01 页 数:368开 本:16开装 帧:I S B N :9787121338144换 版:所属分类:科技 >> 计算机 >> 作业系统内容简介随着套用功能的日益增加,性能问题也逐渐浮出水面,进入我们的视野之中 。本书作者Marcel Weiher在性能调优领域有着丰富的经验,在他的带领下,你将会了解如何提升CPU、记忆体、I/O、图像、Swift等方面的性能,如何在开发过程中定位到性能的瓶颈和问题,他同时还介绍了性能最佳化的编程技巧和最佳实践,从而帮助你写出更高效、更快速的代码 。此外,你还将学习到定位性能问题的工具使用方法以及最佳实践,并跟随示例来学习性能最佳化 。本书适合寻求进阶及所有对性能最佳化感兴趣的iOS 开发人员阅读 。目录目录1 CPU:原理 ...................................................................................................................... 1一个简单的例子 ......................................................................................................................... 2(微)基準的危险 ............................................................................................................. 3更多整数求和的方式 ....................................................................................................... 4Swift.................................................................................................................................. 5其他语言 ........................................................................................................................... 7混编的力量 ................................................................................................................................ 9趋势 .......................................................................................................................................... 10操作成本 .................................................................................................................................. 12複杂度计算 ............................................................................................................................... 14总结 .......................................................................................................................................... 162 CPU:测量和工具 ......................................................................................................... 17命令行工具 ............................................................................................................................... 18top ................................................................................................................................. 18time ............................................................................................................................... 19sample ........................................................................................................................... 19Xcode 测量工具 ........................................................................................................................ 22Instruments................................................................................................................................ 23 设定和数据收集 ............................................................................................................. 24性能分析选项 ................................................................................................................. 25基本分析 ......................................................................................................................... 27原始码 ............................................................................................................................. 29数据挖掘I:Focus ......................................................................................................... 31数据挖掘II:Pruning ..................................................................................................... 34内部测量 .................................................................................................................................. 35测试 ................................................................................................................................ 36dtrace(dynamic tracing,动态跟蹤) .................................................................................... 37职责之外的最佳化 ....................................................................................................................... 38总结 .......................................................................................................................................... 39 3 CPU:陷阱和最佳化技巧 .................................................................................................. 41数据表示 .................................................................................................................................. 41基本类型 ......................................................................................................................... 42字元串 ............................................................................................................................. 45对象 .......................................................................................................................................... 47存取器 ............................................................................................................................. 48公共访问(Public Access) ........................................................................................... 51对象创建和快取 ............................................................................................................. 52可变性和快取 ................................................................................................................. 53惰性求值 ......................................................................................................................... 55快取注意事项 ................................................................................................................. 55 陷阱:通用(中级)表示 ............................................................................................. 57数组和批处理 ................................................................................................................. 58字典 ................................................................................................................................ 60讯息传递 .................................................................................................................................. 63IMP 快取 ......................................................................................................................... 65转发 ................................................................................................................................ 67均匀性和最佳化 ................................................................................................................. 69方法 .......................................................................................................................................... 70陷阱:CoreFoundation ................................................................................................... 70多核 .......................................................................................................................................... 71执行绪(Thread) .............................................................................................................. 72 工作伫列 ......................................................................................................................... 73有节制地最佳化 ........................................................................................................................... 744 CPU 实战:XML 解析 ................................................................................................... 77HTML 扫描器 ........................................................................................................................... 78将回调映射为讯息.................................................................................................................... 81对象 .......................................................................................................................................... 83对象的高效性能 ....................................................................................................................... 85性能评估 .................................................................................................................................. 88调整 .......................................................................................................................................... 91最佳化整个组件:MAX .............................................................................................................. 92MAX 实现 ................................................................................................................................ 94 总结 .......................................................................................................................................... 955 记忆体:原理 .................................................................................................................... 97记忆体层次结构 ........................................................................................................................... 97Mach 虚拟记忆体 ....................................................................................................................... 103堆和栈 .................................................................................................................................... 104栈分配 ........................................................................................................................... 106使用malloc()进行堆分配 ....................................................................................... 108资源管理 ................................................................................................................................ 111垃圾回收 ....................................................................................................................... 111Foundation 对象所有权 ................................................................................................ 112跟蹤垃圾回收 ............................................................................................................... 113 自动引用计数(Automatic Reference Counting) ...................................................... 114过程式资源回收 ........................................................................................................... 115总结 ........................................................................................................................................ 1156 记忆体:测量与工具 ....................................................................................................... 117Xcode 计量表 .......................................................................................................................... 117命令行工具 ............................................................................................................................. 118top ............................................................................................................................... 118heap .............................................................................................................................. 120leaks 及malloc_debug ......................................................................................... 122代码内进行记忆体测量 .............................................................................................................. 123记忆体监测工具 ......................................................................................................................... 124 Leaks .............................................................................................................................. 124Allocations ..................................................................................................................... 125VM Tracker .................................................................................................................... 132计数器与性能监测事件 ............................................................................................... 133总结 ........................................................................................................................................ 1347 记忆体:陷阱和最佳化技巧 ................................................................................................ 137引用计数 ................................................................................................................................ 137避免记忆体泄漏 ............................................................................................................... 139Foundation 对象和基本类型对比 .......................................................................................... 141更小的结构 ............................................................................................................................. 143千禧危机 ....................................................................................................................... 145 压缩 ............................................................................................................................... 145可清除记忆体 ................................................................................................................... 146记忆体与并发 ............................................................................................................................. 146架构注意事项 ......................................................................................................................... 147临时分配与对象快取 .............................................................................................................. 152NSCache 与libcache ............................................................................................................... 153记忆体映射档案 ......................................................................................................................... 154madvise ................................................................................................................................ 157iOS 注意事项 .......................................................................................................................... 158ARC 最佳化 ............................................................................................................................... 158总结 ........................................................................................................................................ 161 8 记忆体管理实战:FilterStream 架构 ............................................................................... 163UNIX 管道及过滤器 ............................................................................................................... 163面向对象的过滤器.................................................................................................................. 165DescriptionStream .................................................................................................................... 166消除description 中的无限递归 ........................................................................... 170数据流层次结构 ..................................................................................................................... 172总结 ........................................................................................................................................ 1739 Swift ............................................................................................................................ 175Apple 所声称的Swift 性能 .................................................................................................... 175语言特性 ....................................................................................................................... 177基準代码 ....................................................................................................................... 179 Swift 性能评估 ........................................................................................................................ 180基本性能特徵 ............................................................................................................... 180集合 ............................................................................................................................... 181更进一步 ................................................................................................................................ 190Nginx HTTP 解析器 ..................................................................................................... 190Freddy JSON 解析器 .................................................................................................... 191图片处理 ....................................................................................................................... 191观察 ............................................................................................................................... 192编译时间 ................................................................................................................................ 193类型推断 ....................................................................................................................... 193泛型特化 ....................................................................................................................... 195 全模组最佳化 ................................................................................................................... 197控制编译时间 ............................................................................................................... 197面向最佳化器编程 ..................................................................................................................... 198一个足够智慧型的编译器 .......................................................................................................... 199最佳化编译器之死 ........................................................................................................... 201实用建议 ....................................................................................................................... 203备用方案 ....................................................................................................................... 204总结 ........................................................................................................................................ 20710 I/O:原理 .................................................................................................................. 209硬体 ........................................................................................................................................ 209硬碟驱动器 ................................................................................................................... 209 固态硬碟 ....................................................................................................................... 211网路 ............................................................................................................................... 212作业系统 ................................................................................................................................ 212抽象概念:位元组流 ....................................................................................................... 212档案I/O ......................................................................................................................... 214网路栈 ........................................................................................................................... 218总结 ........................................................................................................................................ 21811 I/O:测量与工具 ........................................................................................................ 221负形空间:top 与time ....................................................................................................... 222信息概览:iostat 和netstat......................................................................................... 223Instruments.............................................................................................................................. 224 详细追蹤:fs_usage .......................................................................................................... 228总结 ........................................................................................................................................ 23112 I/O:陷阱和最佳化技巧 ................................................................................................ 233将位元组封装为NSData ............................................................................................................ 233记忆体映射异常 ............................................................................................................... 235如何分块 ....................................................................................................................... 237UNIXy I/O ............................................................................................................................... 238网路I/O .................................................................................................................................. 240堆叠传输 ....................................................................................................................... 241限制请求 ....................................................................................................................... 243数据处理 ....................................................................................................................... 244 异步I/O ......................................................................................................................... 245HTTP 服务 .................................................................................................................... 246序列化 .................................................................................................................................... 250记忆体转储 ....................................................................................................................... 251一个简单的XML 格式 ................................................................................................. 252属性列表 ....................................................................................................................... 254归档 ............................................................................................................................... 256序列化总结 ................................................................................................................... 258CoreData ................................................................................................................................. 260批量创建和更新 ........................................................................................................... 261Fetch 和Fault 技术 ....................................................................................................... 263 对象互动 ....................................................................................................................... 266子集 ............................................................................................................................... 266分析 ............................................................................................................................... 267SQLite ..................................................................................................................................... 267关係型和其他非资料库 ............................................................................................... 269事件发布 ................................................................................................................................ 270混合形式 ....................................................................................................................... 271隔离存储 ................................................................................................................................ 272总结 ........................................................................................................................................ 27213 I/O:实战 .................................................................................................................. 273iPhone 游戏字典 ..................................................................................................................... 273 有趣的属性列表 ..................................................................................................................... 277二进制属性列表读取器 ............................................................................................... 278懒载入 ........................................................................................................................... 282避免中间代码 ............................................................................................................... 284逗号分隔值 ............................................................................................................................. 287公共运输调度数据.................................................................................................................. 289站点信息 ....................................................................................................................... 290站点停靠时间检索 ....................................................................................................... 291站点停靠时间导入 ....................................................................................................... 292更快的CSV 解析 .................................................................................................................... 294对象分配 ....................................................................................................................... 294 Push 与Pull 的比较 ...................................................................................................... 296感兴趣的键 ................................................................................................................... 296并行 ............................................................................................................................... 296总结 ........................................................................................................................................ 29914 图像和UI:原理 ........................................................................................................ 301回响能力 ................................................................................................................................ 301软体和API .............................................................................................................................. 302Quartz 和PostScript 图像模型 ............................................................................................... 305OpenGL .................................................................................................................................. 307Metal ....................................................................................................................................... 307图形硬体加速 ......................................................................................................................... 307 从Quartz 到Core Animation .................................................................................................. 311总结 ........................................................................................................................................ 31415 图像和UI:测量和工具 ............................................................................................. 315CPU 分析仪 ............................................................................................................................. 315Quartz 调试 .............................................................................................................................. 317Core Animation 工具 ............................................................................................................... 318当CPU 不再是问题 ................................................................................................................ 319我在测量什幺 ......................................................................................................................... 327总结 ........................................................................................................................................ 32916 图像和UI:陷阱和最佳化技巧 ...................................................................................... 331陷阱 ........................................................................................................................................ 331 最佳化技巧 ................................................................................................................................ 332过多通信导致安装缓慢 .......................................................................................................... 333节流显示 ....................................................................................................................... 333使用节流显示 ............................................................................................................... 335今日安装程式和进度报告 ........................................................................................... 335iPhone 无法承受之重 ............................................................................................................. 336一切都是假象 ......................................................................................................................... 338图像的缩放和剪下 ....................................................................................................... 338缩略图绘製 ................................................................................................................... 340如何确定没有绘製缩略图 ........................................................................................... 341如何真的不绘製缩略图 ............................................................................................... 341如何绘製非缩略图 ....................................................................................................... 342 在iPhone 上绘製直线 ............................................................................................................ 344总结 ........................................................................................................................................ 34617 图像和UI:实战 ........................................................................................................ 347优美的天气套用 ..................................................................................................................... 347更新 ............................................................................................................................... 348探索PNG ...................................................................................................................... 348头脑风暴 ....................................................................................................................... 350JPEG 数据点 ................................................................................................................. 350测量时的小错误 ........................................................................................................... 351JPNG 与JPJP ................................................................................................................ 353优美的启动 ................................................................................................................... 353 Wunderlist 3 ............................................................................................................................. 354Wunderlist 2 ................................................................................................................... 354整体架构 ....................................................................................................................... 355URI 与进程中REST ..................................................................................................... 356最终一致的异步数据存储 ........................................................................................... 357RESTOperation 伫列 ..................................................................................................... 358流畅、反应灵敏的UI .................................................................................................. 359简评Wunderlist ............................................................................................................. 361总结 ........................................................................................................................................ 361
- 和田地区行署领导 李贤
- 2016年中国公募基金和私募基金研究报告
- 我和殭尸有个约会之追杀罗密欧
- 最浪漫的事就是和你一起慢慢变胖
- 元和姓纂
- 肌腱炎和腱鞘炎
- 和坪溪乡
- 撞钉
- 奖励和限制政策
- 探矿权採矿权使用费和价款管理办法