Coder Social home page Coder Social logo

crazyit / gymonitor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from featuretower/gymonitor

0.0 1.0 0.0 4.18 MB

A collection of code for profiling iOS app, such as monitoring FPS.

License: MIT License

Ruby 0.47% Objective-C 89.95% C 7.01% Python 2.58%

gymonitor's Introduction

GYMonitor

GYMonitor是用于监控iOS app性能状况的代码库,目前包括有FPS监控,发现FPS过低会自动产生堆栈,便于在开发过程中发现卡顿问题。

安装

使用CocoaPods

# Podfile
platform :ios, '7.0'
target 'YourTarget'
pod 'GYMonitor'

手工导入

  • 拖动GYMonitor整个文件夹到已有的Xcode工程。值得注意的是GYMonitor里面有CrashReporter.framework这个库。
  • 包含头文件#import "GYMonitor.h"
  • dsymInfo文件夹拷贝到工程文件的同一个目录,然后在工程文件中的Build Phases最后加上一个Run Script,脚本内容为python ${PROJECT_DIR}/dsymInfo/backup.py (Run Script)

使用

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    // normal code...
    
    [self startMonitor];
    
    return YES;
}

- (void)startMonitor {
    [GYMonitor sharedInstance].monitorFPS = YES;
    [GYMonitor sharedInstance].showDebugView = YES;
    [[GYMonitor sharedInstance] startMonitor];
}

- (void)stopMonitor {
    [GYMonitor sharedInstance].monitorFPS = NO;
    [GYMonitor sharedInstance].showDebugView = NO;
    [[GYMonitor sharedInstance] startMonitor];
}

运行效果

  • 在模拟器/真机(真机只能看到部分符号)

fps低

fps卡顿

模拟器上的堆栈

  • 在mac上反解

(反解堆栈菜单) (mac上反解结果)

原理

  • 通过CADisplayLink获取屏幕刷新频率,输出FPS的值
  • 在子线程开启定时器监控FPS的值
  • 当FPS的值过低时,通过CrashReporter获取全部线程的堆栈,保存为$currentController.crash文件
  • 编译项目成功后通过dsymutil产生dSYM文件然后保存,为了节省空间最多保存5个。还有为它们在所的目录添加Spotlight索引,反解堆栈时能让mac os自动找到它们
  • 在手机可通过点击监控条,然后用AirDrop把crash文件传输到mac上,在mac使用symbolicatecrash反解堆栈,为了方便,我使用了Automator为右键点击*.crash文件时添加服务项反解堆栈,点击后会运行脚本去反解堆栈。

gymonitor's People

Contributors

featuretower avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.