Latest 1.0.5
Homepage https://github.com/daisuke-t-jp/Baconian
License MIT
Platforms ios 10.0, osx 10.12, requires ARC
Dependencies Mach-Swift
Authors

Platform
Language Swift%205.0
Build Status
Cocoapods
Carthage compatible

Baconian
Baconian

Introduction

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

  • [x] OS Memory pressure
  • [x] OS CPU load
  • [x] OS Processors load
  • [x] App Memory pressure
  • [x] App CPU load
  • [x] App Thread Information

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

Baconian

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

Baconian

2. Set ReporterCompactView frame

Baconian

Width is 260 and Height is 50.

Demo

There are demos.

Latest podspec

{
    "name": "Baconian",
    "version": "1.0.5",
    "summary": "System information reporter in Swift.",
    "description": "**Baconian** is system information reporter framework in Swift.  nThe reporter provides memory pressure and cpu load.",
    "homepage": "https://github.com/daisuke-t-jp/Baconian",
    "screenshots": [
        "https://raw.githubusercontent.com/daisuke-t-jp/Baconian/master/images/DemoMovie-iOS.gif",
        "https://raw.githubusercontent.com/daisuke-t-jp/Baconian/master/images/DemoMovie-macOS.gif"
    ],
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "daisuke-t-jp": "[email protected]"
    },
    "platforms": {
        "ios": "10.0",
        "osx": "10.12"
    },
    "source": {
        "git": "https://github.com/daisuke-t-jp/Baconian.git",
        "tag": "1.0.5"
    },
    "source_files": "Baconian/**/*.{swift}",
    "ios": {
        "resources": "Baconian/UI/ReporterCompactView/iOS/*.{xib}",
        "frameworks": "UIKit"
    },
    "osx": {
        "resources": "Baconian/UI/ReporterCompactView/macOS/*.{xib}",
        "frameworks": "AppKit"
    },
    "swift_version": "5.0",
    "requires_arc": true,
    "dependencies": {
        "Mach-Swift": []
    }
}

Pin It on Pinterest

Share This