Baconian 1.0.5

Baconian 1.0.5

Maintained by Daisuke T.




Baconian 1.0.5

  • By
  • daisuke-t-jp

Baconian

Platform Language Swift%205.0 Build Status Cocoapods Carthage compatible

Introduction

Baconian is system information reporter framework in Swift.
The reporter(Reporter) provides the following information.

  • OS Memory pressure
  • OS CPU load
  • OS Processors load
  • App Memory pressure
  • App CPU load
  • App Thread Information

And you can also see the load graphically by the view.(ReporterCompactView)

Table of View's symbol meaning.

Symbol Meaning
🍎 OS load line
🍏 Process(App) load line
🐏 Memory usage. 🐏 is RAM(U+1F40F)
🤖 CPU usage(0 - 100%)

Requirements

  • Platforms
    • iOS 10.0+
    • macOS 10.12+
  • Swift 5.0

Installation

Carthage

github "daisuke-t-jp/Baconian"

CocoaPods

use_frameworks!

target 'target' do
pod 'Baconian'
end

Usage

Import framework

import Baconian

Reporter class

1. Confirm ReporterDelegate protocol

class ViewController: ReporterDelegate {

2. Setup and start reporter

let reporter = Reporter()
reporter.delegate = self
reporter.start()

3. Implement delegate

func reporter(_ manager: Reporter, didUpdate data: Reporter.Data) {
    print("# Report")
    
    print("## OS")
    print("### Memory")
    print("- physicalSize: \(data.osMemory.physicalSize.memoryByteFormatString)")
    print("- freeSize: \(data.osMemory.freeSize.memoryByteFormatString)")
    print("- inactiveSize: \(data.osMemory.inactiveSize.memoryByteFormatString)")
    print("- wireSize: \(data.osMemory.wireSize.memoryByteFormatString)")
    print("- usedSize: \(data.osMemory.usedSize.memoryByteFormatString)")
    print("- unusedSize: \(data.osMemory.unusedSize.memoryByteFormatString)")
    print("")
    
    print("### CPU")
    print(String.init(format: "- userUsage: %.2f", data.osCPU.userUsage))
    print(String.init(format: "- systemUsage: %.2f", data.osCPU.systemUsage))
    print(String.init(format: "- idleUsage: %.2f", data.osCPU.idleUsage))
    print(String.init(format: "- niceUsage: %.2f", data.osCPU.niceUsage))
    print(String.init(format: "- usage: %.2f", data.osCPU.usage))
    print("")
    
    print("### Processors")
    for i in 0..<data.osProcessors.count {
        print("- Core No.\(i)")
        print(String.init(format: "    - userUsage: %.2f", data.osCPU.userUsage))
        print(String.init(format: "    - systemUsage: %.2f", data.osCPU.systemUsage))
        print(String.init(format: "    - idleUsage: %.2f", data.osCPU.idleUsage))
        print(String.init(format: "    - niceUsage: %.2f", data.osCPU.niceUsage))
        print(String.init(format: "    - usage: %.2f", data.osCPU.usage))
        print("")
    }
    
    
    print("## Process")
    print("### Memory")
    print("- residentSize: \(data.processMemory.residentSize.memoryByteFormatString)")
    print("")
    
    print("### CPU")
    print(String.init(format: "- usage: %.2f", data.processCPU.usage))
    print(String.init(format: "- time: %.2f", data.processCPU.time))
    print("")
    
    print("### Thread")
    print("- totalNum: \(data.processThread.totalNum)")
    print("- busyNum: \(data.processThread.busyNum)")
    print("- idleNum: \(data.processThread.idleNum)")
    print("")
}

4. Stop reporter

reporter.stop()

ReporterCompactView class

Add ReporterCompactView by Programmatically

let reporterView = ReporterCompactView(frame: CrossPlatformRect(x: 0, 
                                                                y: 0, 
                                                            width: ReporterCompactView.xibWidth,
                                                            height: ReporterCompactView.xibHeight))

self.view.addSubview(reporterView)

Add ReporterCompactView by Interface Builder

1. Set UIView's custom class to ReporterCompactView

2. Set ReporterCompactView frame

Width is 260 and Height is 50.

Demo

There are demos.