|
1 | 1 | # cocoapods-project-hmap
|
2 | 2 |
|
3 |
| -此插件思路来源于[《一款可以让大型iOS工程编译速度提升50%的工具》](https://tech.meituan.com/2021/02/25/cocoapods-hmap-prebuilt.html)。通过使用hmap代替文件路径搜索优化预处理阶段中头文件搜索的性能实现编译速度提升。 |
| 3 | +此插件思路来源于[《一款可以让大型iOS工程编译速度提升50%的工具》](https://tech.meituan.com/2021/02/25/cocoapods-hmap-prebuilt.html)。通过使用 header map (以下简称 hmap ) 代替文件路径搜索优化预处理阶段中头文件搜索的性能实现编译速度提升。 |
4 | 4 |
|
5 | 5 | [English](./README_en.md)
|
6 | 6 |
|
7 |
| -## 效果测试 |
8 |
| - |
9 |
| -我在另一个项目 [hmap-benchmark](https://github.com/chenxGen/hmap-benchmark/) 写了几个测试用例,统计并输出增加M个源文件,N个第三方库在使用和不使用插件的情况下的编译时间. |
10 |
| - |
11 |
| -最新一次跑 `run_benchmark.rb` 脚本的时间统计为: |
12 |
| - |
13 |
| -- Mac mini (Intel i7/16g) : |
14 |
| - |
15 |
| - ``` |
16 |
| - +--------------------------------------+--------------------+------------------------------------------------------------------------------------------------------------------------+ |
17 |
| - | Case | Average(s) | Detail(s) | |
18 |
| - +--------------------------------------+--------------------+------------------------------------------------------------------------------------------------------------------------+ |
19 |
| - | 100 source files & 125 pods (origin) | 192.43606980641684 | [218.57447242736816, 178.7542200088501, 179.97951698303223] | |
20 |
| - | 100 source files & 125 pods (plugin) | 165.76690363883972 | [166.8555600643158, 165.40182876586914, 165.04332208633423] | |
21 |
| - | > optimization (speed) | 16.09% | | |
22 |
| - | > optimization (time cost) | 13.86% | | |
23 |
| - | 1 source files & 125 pods (origin) | 170.00553512573242 | [175.31463813781738, 173.79285717010498, 160.9091100692749] | |
24 |
| - | 1 source files & 125 pods (plugin) | 124.49473492304485 | [123.54309391975403, 124.4949209690094, 125.4461898803711] | |
25 |
| - | > optimization (speed) | 36.56% | | |
26 |
| - | > optimization (time cost) | 26.77% | | |
27 |
| - | Total (origin) | 181.22080246607462 | [218.57447242736816, 178.7542200088501, 179.97951698303223, 175.31463813781738, 173.79285717010498, 160.9091100692749] | |
28 |
| - | Total (plugin) | 145.1308192809423 | [166.8555600643158, 165.40182876586914, 165.04332208633423, 123.54309391975403, 124.4949209690094, 125.4461898803711] | |
29 |
| - | > optimization (speed) | 24.87% | | |
30 |
| - | > optimization (time cost) | 19.91% | | |
31 |
| - +--------------------------------------+--------------------+------------------------------------------------------------------------------------------------------------------------+ |
32 |
| - ``` |
33 |
| -- Mac air (Apple M1/16g) : |
34 |
| - |
35 |
| - ``` |
36 |
| - +--------------------------------------+-------------------+--------------------------------------------------------------------------------------------------------------------+ |
37 |
| - | Case | Average(s) | Detail(s) | |
38 |
| - +--------------------------------------+-------------------+--------------------------------------------------------------------------------------------------------------------+ |
39 |
| - | 100 source files & 125 pods (origin) | 95.07198365529378 | [91.36949586868286, 96.10968923568726, 97.73676586151123] | |
40 |
| - | 100 source files & 125 pods (plugin) | 91.2074584166289 | [90.87663986448735, 90.77357686752014, 91.97326111793518] | |
41 |
| - | > optimization (speed) | 4.24% | | |
42 |
| - | > optimization (time cost) | 4.06% | | |
43 |
| - | 1 source files & 125 pods (origin) | 81.564133644104 | [80.95829105377197, 82.07278513988386, 81.66132473945618] | |
44 |
| - | 1 source files & 125 pods (plugin) | 79.28314812668217 | [78.21958923339844, 80.21097787748413, 79.17887886892395] | |
45 |
| - | > optimization (speed) | 2.98% | | |
46 |
| - | > optimization (time cost) | 2.89% | | |
47 |
| - | Total (origin) | 88.3180586496989 | [91.36949586868286, 96.10968923568726, 97.73676586151123, 80.95829105377197, 82.07278513988386, 81.66132473945618] | |
48 |
| - | Total (plugin) | 85.2053037/161153 | [90.87663986448735, 90.77357686752014, 91.97326111793518, 78.21958923339844, 80.21097787748413, 79.17887886892395] | |
49 |
| - | > optimization (speed) | 3.65% | | |
50 |
| - | > optimization (time cost) | 3.52% | | |
51 |
| - +--------------------------------------+-------------------+--------------------------------------------------------------------------------------------------------------------+ |
52 |
| - ``` |
53 |
| - |
54 |
| -从上面的输出日志可以看出,插件可以带来3%-36%的编译速度提升,在使用Intel芯片的机器上优化效果还是挺好的,但是在使用Apple M1芯片的机器上效果就约等于没有了,只能说是M1的性能实在牛批。**如果你用的是M1,这里建议直接 `return`** |
| 7 | +## 首先,什么样的项目适合使用这个插件? |
| 8 | + |
| 9 | +1. **仅适合使用 objective-c 作为主要开发语言项目**,因为 swift 没有头文件的概念,从其编译原理上看并没有什么帮助; |
| 10 | +2. **不适合 Podfile 中 开启了 `use_frameworks!` or `use_modular_headers!` 的项目使用**,由于为了兼容 clang module 特性,采取的策略是不对开启了 DEFINES_MODULE 的项目生成 hmap; |
| 11 | +3. **不适用于 CPU 为 M1 以及后续 M 系列芯片的 Mac**,因为使用之后提升也很小; |
| 12 | + |
| 13 | +综上,比较适合 old school 的项目使用此插件,如果你的项目满足以上条件推荐使用此插件,不然可能收效甚微,不建议继续往下看了。 |
| 14 | + |
| 15 | +## 插件名的由来 |
| 16 | + |
| 17 | +最初版本的插件仅仅为了给 Pod Project 和 Host Project 提供一个可行的跨项目 hmap 方案,填补 Xcode 自带的仅支持 Project 内部的 hmap 的空白,由此得名:cocoapods-project-hmap. |
55 | 18 |
|
56 | 19 | ## 环境要求
|
57 | 20 |
|
@@ -92,6 +55,10 @@ target 'app' do
|
92 | 55 | end
|
93 | 56 | ```
|
94 | 57 |
|
| 58 | +## 联系方式 |
| 59 | + |
| 60 | +QQ: 930565063 |
| 61 | + |
95 | 62 | ## License
|
96 | 63 |
|
97 | 64 | cocoapods-project-hmap is released under the MIT license. See LICENSE for details.
|
0 commit comments