Code Monkey home page Code Monkey logo

gdperformanceview-swift's Introduction

GDPerformanceView-Swift

Shows FPS, CPU and memory usage, device model, app and iOS versions above the status bar and report FPS, CPU and memory usage via delegate.

Carthage compatible Pod Version Swift Version Swift Version Swift Version Plaform License MIT

Alt text Alt text Alt text Alt text

Installation

Simply add GDPerformanceMonitoring folder with files to your project, or use CocoaPods.

Carthage

Create a Cartfile that lists the framework and run carthage update. Follow the instructions to add $(SRCROOT)/Carthage/Build/iOS/GDPerformanceView.framework to an iOS project.

github "dani-gavrilov/GDPerformanceView-Swift" ~> 2.1.1

Don't forget to import GDPerformanceView by adding:

import GDPerformanceView

CocoaPods

You can use CocoaPods to install GDPerformanceView by adding it to your Podfile:

platform :ios, '8.0'
use_frameworks!

target 'project_name' do
	pod 'GDPerformanceView-Swift', '~> 2.1.1'
end

Don't forget to import GDPerformanceView by adding:

import GDPerformanceView_Swift

Usage example

Simply start monitoring. Performance view will be added above the status bar automatically. Also, you can configure appearance as you like or just hide the monitoring view and use its delegate.

You can find example projects here.

Start monitoring

By default, monitoring is paused. Call the following command to start or resume monitoring:

PerformanceMonitor.shared().start()

or

self.performanceView = PerformanceMonitor()
self.performanceView?. start()

This won't show the monitoring view if it was hidden previously. To show it call the following command:

self.performanceView?.show()

Pause monitoring

Call the following command to pause monitoring:

self.performanceView?.pause()

This won't hide the monitoring view. To hide it call the following command:

self.performanceView?.hide()

Displayed information

You can change displayed information by changing options of the performance monitor:

self.performanceView?.performanceViewConfigurator.options = .all

You can choose from:

  • performance - CPU usage and FPS.
  • memory - Memory usage.
  • application - Application version with build number.
  • device - Device model.
  • system - System name with version.

Also you can mix them, but order doesn't matter:

self.performanceView?.performanceViewConfigurator.options = [.performance, .application, .system]

By default, set of [.performance, .application, .system] options is used.

You can also add your custom information by using:

self.performanceView?.performanceViewConfigurator.userInfo = .custom(string: "Launch date \(Date())")

Keep in mind that custom string will not automatically fit the screen, use \n if it is too long.

Appearance

You can change monitoring view appearance by changing style of the performance monitor:

Call the following command to change output information:

self.performanceView?.performanceViewConfigurator.style = .dark

You can choose from:

  • dark - Black background, white text.
  • light - White background, black text.
  • custom - You can set background color, border color, border width, corner radius, text color and font.

By default, dark style is used.

Also you can override prefersStatusBarHidden and preferredStatusBarStyle to match your expectations:

self.performanceView?.statusBarConfigurator.statusBarHidden = false
self.performanceView?.statusBarConfigurator.statusBarStyle = .lightContent

Interactions

You can interact with performance view via gesture recognizers. Add them by using:

self.performanceView?.performanceViewConfigurator.interactors = [tapGesture, swipeGesture]

If interactors is nil or empty point(inside:with:) of the view will return false to make all touches pass underneath. So to remove interactors just call the following command:

self.performanceView?.performanceViewConfigurator.interactors = nil

By default, interactors are nil.

Delegate

Set the delegate and implement its method:

self.performanceView?.delegate = self
func performanceMonitor(didReport performanceReport: PerformanceReport) {
	print(performanceReport.cpuUsage, performanceReport.fps, performanceReport.memoryUsage.used, performanceReport.memoryUsage.total)
}

Requirements

  • iOS 9.0+
  • xCode 12.0+

Donations

Wanna say thanks? You can do it using Patreon.

Meta

Daniil Gavrilov - VK - FB

I will be pleased to know that your project uses this framework. You can send a link to your project in App Store to my email - [email protected].

License

GDPerformanceView is available under the MIT license. See the LICENSE file for more info.

gdperformanceview-swift's People

Contributors

basthomas avatar dani-gavrilov avatar jinjiegu avatar tinora avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gdperformanceview-swift's Issues

Need some example to add to my app

Using the pod-file and updating my project given the example is fairly easy, but I'm missing instructions on how to get it running?!
I tried adding the start-monitoring to my AppDelegate.swift

private func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. }

and the stop-monitoring to my AppDelegate.swift

func applicationWillTerminate(_ application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. gdpMonitoringStop() }

but getting compile-errors.
Do I need to add 'import GDPMonitoring' after 'import UIKit' in my AppDelegate.swift ?

Performance not show on ipad device

Hello,
I have a problem on ipad, after start PerformanceMonitor, there are nothing show on screen about monitoring. This issue cause when run app on ipad without debugging mode.

Detect tap

Is it possible to detect a tap on the performance view? I would like to do a custom action when the user taps on it.

Thank you very much

Support for Interface Orientation

It would be nice if this library supported interface rotation gracefully.

Currently, if I start the app in portrait and rotate to landscape, the performance view becomes centered on the top left corner.

Tested on iPhone 6, iOS 10.2

Add custom info

Is it possible to add custom info info in the performance view?

For example, I would like to add the date when the user started the application.

Thank you a lot !

iOS 9 status bar style "lightContent" not working

Now that the status bar is visible on iOS 9 I recognized that the status bar style set by the view controller is ignored. My code is pretty simple:

`
override var prefersStatusBarHidden: Bool {
return false
}

override var preferredStatusBarStyle: UIStatusBarStyle {
return isDarkMode ? .lightContent : .default
}
`

The status bar style is switching on iOS 10 but not on iOS 9 (where it is always default).

iPhone X support

Hi!

I'm sure there's a cool way of avoiding the notch on the iPhone X. That would be great!

Thanks,

Mauro

App crashes using iPhone with iOS 12.4.8

Hello,
when trying to run my app with the latest GDPerfomanceView-Swift 2.1.0 on an iPhone with iOS 12.4.8 it crashes upon start at:

extension UIApplication {
    
    var keyWindow: UIWindow? {
        if #available(iOS 13, *) {
            return UIApplication.shared.windows.first { $0.isKeyWindow }
        } else {
            return UIApplication.shared.keyWindow
        }
    }
...
}

this results in an endless getter loop:

#2	0x00000001087ab9b4 in UIApplication.keyWindow.getter at Example/Pods/GDPerformanceView-Swift/GDPerformanceView-Swift/GDPerformanceMonitoring/Extensions.swift:28
...
#5309	0x00000001087abb2c in UIApplication.keyWindow.getter at Example/Pods/GDPerformanceView-Swift/GDPerformanceView-Swift/GDPerformanceMonitoring/Extensions.swift:31

Does the FPS measurement detect dropped frames during compositing?

I've got a performance tool that similarly uses CADisplayLink to try and measure the framerate / dropped frames. But in my tests back during iOS 7 and 8, CADisplayLink's callback timing was only affected when a frame drop happened due to slowness in-process, for example if there's a lot of auto layout work. My understanding of UIKit's drawing is that after the layers are all prepared, they are composited out-of-process in iOS's equivalent of the WindowServer, as OpenGL / Metal rectangles. So if compositing is too slow, say because you have a bunch of expensive layers with blurring and rounded corners, the display link callback will still happen right on time. You'll see a slow frame rate, but the meter will show 60.

I did an ugly hack to solve this that worked in iOS 7 and 8, but doesn't work anymore in iOS 9 and 10. Did you have a way to address this? If we can figure it out, we can improve both our projects. If not, you may want to write some kind of disclaimer in your readme. :)

If you want to test this out, the repo I linked to has an example project, and you can add your meter to it. You'd want to use the ios9 branch.

内存泄漏

GDPerformanceView 文件 267行分配内存后没有释放。

Change text size, view size

Hello,
When run GDPerfomanceView-Swift, I see font size / view size in performance view are too small. Can I change it?

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.