Skip to content

ahimahas/MethodTimeTracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MethodTimeTracker CocoaPods Platform

MethodTimeTracker is a module that can measure a time to spend in each method.

When can be used

If you felt that your application works a bit slow and you want to know where is the bottleneck in the code level, you are in the right place.

Method time tracker measures for each method that how much time they spend. You can specify a single method you want to measure, or just check all methods in a class.

Sample result

Here is the result of measuring all methods in Sample project. The return value is a time in second.

sameple screenshot

Installation

Use the CocoaPods

pod 'MethodTimeTracker'

and import header file

#import <NSObject+MethodTimeTracker.h>

If you want to use MethodTimeTracker without setting CocoaPods, you can download codes in MethodTimeTracker folder directly and add it to your project.

How to use

  • Measure a single method
- (instancetype)init {
  ...
  
  //! with method name in String value
  [self trackingMethod:@"viewDidLoad"];
  
  //! or with method name in Selector
  [self trackingMethodWithSelector:@selector(viewDidLoad)];
}
  • Measure multiple methods
- (instancetype)init {
  ...
  
  //! with method name in String value
  [self trackingMethods:@[@"viewDidLoad", @"privateMethod:"]];
  
  //! or with method name in Selector
  [self trackingMethodWithSelectors:@selector(viewDidLoad), @selector(privateMethod:), nil];
}
  • Measure all methods in class
- (instancetype)init {
  ...
  
  //! measure all methods
  [self measureAllMethodsTime];
}
  • Want to show all measured time with sorted
//! at a point that you want to see logs.
//! The result will be shown sorted by desc order
...
[self showTrackedMethodTimeLogs];
...

sameple screenshot

Release history: 1.2.1

  • bug fix when swizzling dealloc method