WatchdogInspector counts your app's framerate and displays the fps in the status bar. The coloured status bar lets you know when your framerate drops below 60 fps. If everything is fine your status bar gets happy and will stay green. To detect unwanted main thread stalls you can set a custom watchdog timeout.
- Status bar displays the current framerate in fps (measured every 2 seconds)
- Colours the status bar from green (good fps) to red (bad fps)
- Custom watchdog timeout: Exception when main thread stalls for a defined time
pod "WatchdogInspector"
and run pod install
You can see the example project how to setup and run WatchdogInspector
Make sure that you don't use WatchdogInspector
in production.
You can use Carthage. Specify in Cartfile:
github "tapwork/WatchdogInspector"
Objective-C | Swift
After launch or whenever you want.
import WatchdogInspector
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
TWWatchdogInspector.start()
return true
}
####Stop To stop it just call
TWWatchdogInspector.stop()
You can set a custom watchdog timeout for stalling exceptions (Default: 3 seconds)
TWWatchdogInspector.setStallingThreshhold(10.0)
You could also disable the Main Thread exceptions
TWWatchdogInspector.setEnableMainthreadStallingException(false)
####Logging To log all measured framerates you can log them in the console by calling (Default: on)
TWWatchdogInspector.setUseLogs(true)
There are basically two timers running to measure the framerate.
-
The background thread timer fires every 2 seconds to count how many frames were set by the main thread. Ideally the result would be 120 frames in 2 seconds to get 60 fps. The background timer resets the frames counter every event. He also sends the measured fps to the status bar on the main thread.
-
The main thread timer should fire every 1/60 second (60 fps is optimum for a smooth animation) to increment the frames counter. If the main thread is blocked and can't run every 1/60 second the framerate will drop the 60 fps.
There is also a run loop observer running to detect main thread stalls for a defined timeout. If the timeout has been reached an exception will be thrown.
- HeapInspector Find memory issues & leaks in your iOS app