Latest 1.0.5
Homepage https://github.com/huakucha/TTAnalyzeLoadTime
License MIT
Platforms ios 8.0
Authors

通过Mach-O文件NonlazyClassList构建动态库进行iOS load方法耗时检测

How To Get Started

简介

  • 仓库中提供了源码以及二进制的文件,源码提供了整个AnalyzeLoadTime的全部文件TTLoadTime.mm,二进制文件为一个动态库(为什么提供动态库文末有介绍),动态库为尽可能提前执行Load Method Swizzling提供了可能
  • 重写_getObjc2NonlazyCategoryList_getObjc2NonlazyClassList(runtime源码中有介绍),可以快速拿到全部load的所属Class以及load 的IMP地址
  • 防止运行环境被破坏使用method_setImplementation构建block执行原函数
  • 寻找mach-o中的load以及Swizzle共耗时4毫秒

Podfile

To integrate TTAnalyzeLoadTime into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

target 'TargetName' do
pod 'TTAnalyzeLoadTime', '~> 1.0'
end

Then, run the following command:

$ pod install

Usage

#import <TTLoadTime/TTLoadTime.h>

printLoadCostsInfo();

2018-12-14 17:57:48.838908+0800 TTAnalyzeLoadTime_Example[10937:6344725] >> all load cost info below :
2018-12-14 17:57:48.838934+0800 TTAnalyzeLoadTime_Example[10937:6344725] 
2018-12-14 17:57:48.838953+0800 TTAnalyzeLoadTime_Example[10937:6344725] PodLoadTime - 0.005083391442894936ms
2018-12-14 17:57:48.838962+0800 TTAnalyzeLoadTime_Example[10937:6344725] PodLoadTime(LoadTimer) - 0.005166628398001194ms
2018-12-14 17:57:48.838968+0800 TTAnalyzeLoadTime_Example[10937:6344725] TTViewController - 0.02345838584005833ms
2018-12-14 17:57:48.838974+0800 TTAnalyzeLoadTime_Example[10937:6344725] TTViewController(LoadTimer) - 0.005333335138857365ms
2018-12-14 17:57:48.838980+0800 TTAnalyzeLoadTime_Example[10937:6344725] 

TODO

  1. 白名单
  2. 格式化打印(打印目前只能在控制台而且打印比较粗糙)

参考文章

Latest podspec

{
    "name": "TTAnalyzeLoadTime",
    "version": "1.0.5",
    "summary": "A short description of TTAnalyzeLoadTime.",
    "description": "TODO: Add long description of the pod here.",
    "homepage": "https://github.com/huakucha/TTAnalyzeLoadTime",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "huakucha": "[email protected]"
    },
    "source": {
        "git": "https://github.com/huakucha/TTAnalyzeLoadTime.git",
        "tag": "1.0.5"
    },
    "platforms": {
        "ios": "8.0"
    },
    "vendored_frameworks": "Products/*.framework"
}

Pin It on Pinterest

Share This