Skip to content

统计程序的界面的FPS信息,便于分析界面的性能

Notifications You must be signed in to change notification settings

jayhe/FPSOfViewController

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FPSOfViewController


[TOC]

功能介绍

  1. 统计每个界面的FPS的变化曲线

如何使用

  • 将HCFPS目录下的Classes加入到工程中
  • 默认是DEBUG模式下会去统计界面的FPS信息,如果想却掉这个限制,在下面的代码将条件编译的去掉
@implementation UIViewController (FPS)

+ (void)load
{
#if DEBUG
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        Method didLoadMethod = class_getInstanceMethod(self, @selector(viewDidLoad));
        Method fps_didLoadMethod = class_getInstanceMethod(self, @selector(fps_viewDidLoad));
        method_exchangeImplementations(didLoadMethod, fps_didLoadMethod);
        
        Method viewWillDisappearMethod = class_getInstanceMethod(self, @selector(viewWillDisappear:));
        Method fps_viewWillDisappearMethod = class_getInstanceMethod(self, @selector(fps_viewWillDisappear:));
        method_exchangeImplementations(viewWillDisappearMethod, fps_viewWillDisappearMethod);
    });
#endif
}
  • 有些界面你不想去统计FPS信息,也可以设置忽略一些类的实例不统计
+ (void)initialize
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _ignoreControllers = @[@"UICompatibilityInputViewController",
                              @"UIAlertController",
                              @"UISplitViewController",
                              @"UIInputWindowController"];
    });
}
  • 运行效果图

Alt text

点击可以查看某个控制器的FPS的变化曲线

Alt text

About

统计程序的界面的FPS信息,便于分析界面的性能

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published