Skip to content

MainasuK/FPSIndicator

Repository files navigation

FPSIndicator

Swift Version License Platform

demo

Features

  • Display FPS (up to 120Hz)
  • Drag to move
  • Customize appearance
  • Optional “geiger counter” functionality that reports dropped frames as an audible click
  • Support Swift package manager

Requirements

  • iOS 14.0+

Note

Please check Optimizing ProMotion Refresh Rates for iPhone 13 Pro and iPad Pro to adapt high refresh rate.

Usage example

import UIKit

#if DEBUG
import FPSIndicator
#endif

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

    var window: UIWindow?

    #if DEBUG
    var fpsIndicator: FPSIndicator?
    #endif

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        guard let windowScene = (scene as? UIWindowScene) else { return }
        window = UIWindow(windowScene: windowScene)

        window?.rootViewController = UINavigationController(rootViewController: ViewController())
        window?.makeKeyAndVisible()

        #if DEBUG
        fpsIndicator = FPSIndicator(windowScene: windowScene)
        FPSIndicator.geigerCounterEnabled = true            // optional
        FPSIndicator.geigerEnableWhenFrameDropBeyond = 20   // tick when frame drop more then 20FPS (a.k.a under 40FPS in 60FPS device)
        #endif
        
        // Note:
        // The FPSIndicator will create a overlay transparent window
        // which may break your status bar apperance by accident.
    }
}

Acknowledgements

Meta

Cirno MainasuK – @MainasuK[email protected]

Distributed under the MIT license. See LICENSE for more information.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages