Skip to content

Repository files navigation

🍎 macOS Hardware Info

Professional Hardware Diagnostics, Multi-Drive Benchmarking & AI Silicon Performance Suite for macOS

Python macOS PyTorch NumPy License Code Style

High-precision hardware telemetry, physical drive I/O benchmarking, and Apple Silicon / Intel compute stress testing unified into a single standalone tool.

Engineered by samuraidev β€’ Portfolio

Key Capabilities β€’ Architecture β€’ CLI & Interactive Usage β€’ Storage Engine β€’ Power Subsystem β€’ AI Benchmarks


🎯 Key Capabilities

macOS-Hardware-info.py delivers unified, low-level diagnostics and scientific hardware telemetry across Intel (T2) and Apple Silicon (M1/M2/M3/M4) architectures:

  1. Modular Diagnostic Architecture β€” Interactive console menu with 5 targeted workflows and dedicated CLI flags for headless automation.
  2. Comprehensive Storage Diagnostics & Speed Testing β€” S.M.A.R.T. health, TBW tracking, and unbuffered parallel I/O speed measurement for internal SSDs and external drives (USB-C, Thunderbolt, UASP).
  3. Dual-Layer Battery & Power Telemetry β€” Full parity with official macOS Battery Health Management (BHM) paired with raw IOKit electrochemical data (design mAh, nominal capacity, cycles, cell temperature, and voltage).
  4. AI Silicon Stress Testing β€” Real hardware compute benchmarks across CPU (FP32 GFLOPS via BLAS), GPU (FP16 TOPS via PyTorch Metal MPS), and Apple Neural Engine (FP16/INT8 TOPS via CoreML).
  5. Logic Board & Bus Integrity Audit β€” Live status checks for Camera, Audio, Secure Enclave (Touch ID), Bluetooth, SMC thermal pressure, Fan RPM, Kernel Panic logs, and I2C/SPI bus mining.

πŸ—οΈ Modular Architecture

The diagnostic engine is organized into decoupled, independent suites designed for single-responsibility execution:

macOS-Hardware-info.py
β”‚
β”œβ”€β”€ [Data Models & Protocols]
β”‚   β”œβ”€β”€ DiskInfo              β†’ Hardware metadata & location descriptors
β”‚   β”œβ”€β”€ SmartReport           β†’ S.M.A.R.T. metrics, TBW & thermal telemetry
β”‚   └── BenchmarkResults      β†’ Computational throughput & hardware specs
β”‚
β”œβ”€β”€ [Suite 1: AI & Compute Benchmarks]
β”‚   β”œβ”€β”€ benchmark_cpu()       β†’ High-intensity FP32 matrix multiplication (GFLOPS)
β”‚   β”œβ”€β”€ benchmark_gpu()       β†’ FP16 Tensor GEMM via PyTorch MPS (TOPS)
β”‚   └── benchmark_npu()       β†’ CoreML Neural Engine MLProgram stress test (TOPS)
β”‚
β”œβ”€β”€ [Suite 2: Storage & Multi-Drive Engine]
β”‚   β”œβ”€β”€ find_physical_disks() β†’ Physical drive enumeration (diskutil & plistlib)
β”‚   β”œβ”€β”€ get_disk_mount_point()β†’ Dynamic writable mount point resolution (/Volumes/...)
β”‚   β”œβ”€β”€ get_smart_data()      β†’ Multi-protocol SMART probe (NVMe, SATA, Bridge descriptors)
β”‚   └── benchmark_disk_speed()β†’ Multi-threaded unbuffered I/O benchmark (fcntl.F_NOCACHE)
β”‚
β”œβ”€β”€ [Suite 3: Logic Board & Peripheral Audit]
β”‚   β”œβ”€β”€ check_logic_board_health()  β†’ BHM official health, IOKit mAh, SMC & Panics
β”‚   └── check_peripherals_and_buses() β†’ Camera, Audio, Touch ID, Bluetooth & Bus logs
β”‚
└── [Execution Orchestrator]
    β”œβ”€β”€ select_execution_option()   β†’ Interactive console selector
    β”œβ”€β”€ parse_arguments()           β†’ CLI argument parser (argparse)
    └── save_report_file()          β†’ Automated persistent .txt log generation

πŸš€ Usage & Execution Flow

The tool requires sudo privileges to communicate with IOKit, smartctl, powermetrics, and raw block storage descriptors.

# Execute with administrative privileges
sudo python3 macOS-Hardware-info.py

Interactive Console Menu

When launched without arguments, the script presents an interactive menu:

════════════════════════════════════════════════════════════════════════════════
  macOS HARDWARE INFO - Complete Hardware Diagnostics
════════════════════════════════════════════════════════════════════════════════
  Select diagnostic suite to execute:

  [1] πŸš€ Run All Tests (Full Suite + Persistent .txt Report Generation)
  [2] 🧠 Performance Benchmarks (CPU, GPU & AI with PyTorch)
  [3] πŸ’Ύ Storage Diagnostics (Internal & External SSDs/HDDs)
  [4] πŸ”¬ Hardware Diagnostics (Logic Board, Peripherals & Buses)
  [5] ❌ Exit

CLI Flags (Automation & CI/CD)

For headless execution or script automation, specific flags bypass the interactive menu:

Flag Long Argument Description
-a --all Executes all test suites and generates {Mac_Model_Serial}.txt report
-i --ai Runs CPU, GPU, and NPU performance benchmarks
-d --disks Runs internal and external storage S.M.A.R.T. and I/O speed benchmarks
-w --hardware Runs Logic Board health, peripheral presence, and bus communication audit
-h --help Displays command-line help and usage options
# Examples:
sudo python3 macOS-Hardware-info.py --disks
sudo python3 macOS-Hardware-info.py --ai
sudo python3 macOS-Hardware-info.py --all

πŸ’Ύ Storage & Multi-Drive Engine

Multi-Drive & External Enclosure Support

The storage engine automatically detects and classifies both internal and external storage media (Apple Fabric NVMe, PCIe SSDs, SATA drives, USB 3.2, and Thunderbolt enclosures):

  • Physical Node Discovery: Uses diskutil list -plist to parse all physical device nodes (/dev/disk0, /dev/disk1, etc.) independently of synthesized APFS containers.
  • Dynamic Mount Point Resolution: Resolves active writable mount paths (/Volumes/DriveName) across partitioned and unpartitioned volumes for secondary and external drives.
  • Multi-Probe S.M.A.R.T. Ingestion: Automatically attempts communication across NVMe, ATA/SATA, and SCSI translation bridge layers (-d sat, -d sntasmedia, -d sntrealtek, -d sntjmicron).
  • Darwin Bridge Awareness: Accurately identifies USB mass storage limitations in macOS, displaying clear diagnostic status when hardware bridge pass-through is restricted by the operating system kernel.

Unbuffered Parallel I/O Speed Test

Measures physical drive throughput while bypassing macOS Unified Memory caching:

               [ Application Buffer (16 MB Chunks) ]
                                β”‚
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β–Ό (Parallel ThreadPool Workers)β–Ό
       Worker 1  Worker 2  Worker 3  Worker 4 ... Worker 8
                 β”‚         β”‚         β”‚         β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
                   fcntl.F_NOCACHE Bypass
                                β”‚
                     [ Unified RAM (ARC) ] ── (Bypassed)
                                β”‚
                     [ Physical NAND / Bus ]
  • Cache Bypass (fcntl.F_NOCACHE): Prevents macOS Unified Memory (ARC) from caching benchmark payload blocks, ensuring direct NAND read/write measurement.
  • High Queue Depth Simulation: Spawns 8 concurrent worker threads via ThreadPoolExecutor with 16 MB chunk sizes to saturate PCIe 4.0/5.0 and high-speed USB-C buses.
  • Entropy Protection: Employs pseudo-random data streams (os.urandom) to prevent hardware controller compression engines from artificially inflating throughput metrics.

πŸ”‹ Battery & Power Subsystem

The power diagnostic module features a dual-layer architecture combining certified system metrics with low-level electrochemical data:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              macOS Power Diagnostic Engine                β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚   Layer 1: Official BHM     β”‚   Layer 2: IOKit Hardware   β”‚
β”‚   (SPPowerDataType XML)     β”‚   (AppleSmartBattery Plist) β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ β€’ Maximum Capacity (98%)    β”‚ β€’ Design Capacity (8579 mAh)β”‚
β”‚ β€’ Health Condition (Normal) β”‚ β€’ Nominal Charge (8305 mAh) β”‚
β”‚ β€’ Calibrated System Level   β”‚ β€’ Raw Max Charge (8061 mAh) β”‚
β”‚                             β”‚ β€’ Cycle Count & Voltage     β”‚
β”‚                             β”‚ β€’ Real-time Cell Temp (Β°C)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  1. Official Battery Health Management (BHM): Retrieves certified maximum capacity percentages matching Apple System Settings 1:1 via structured XML parsing.
  2. Electrochemical IOKit Registry: Extracts factory design capacity (DesignCapacity), temperature-compensated nominal capacity (NominalChargeCapacity), instantaneous fuel gauge registers (AppleRawMaxCapacity), cycle counts, cell voltage, and thermistor readings.

🧠 AI & Silicon Benchmarks

Designed to measure true compute roofline limits across all execution units on Apple Silicon and Intel hardware:

Target Framework / Engine Workload Metric
CPU NumPy (Apple Accelerate BLAS) 2048Γ—2048 FP32 Matrix Multiplication GFLOPS (FP32)
GPU PyTorch (Metal Performance Shaders) 4096Γ—4096 FP16 Tensor GEMM TOPS (FP16)
NPU CoreML (Apple Neural Engine) 5-layer Deep Convolutional Network TOPS (FP16 & INT8)
  • Deterministic Hardware Stress: GEMM (General Matrix Multiply) operations maintain an arithmetic intensity $> 1300\text{ FLOPs/Byte}$, ensuring benchmarks remain compute-bound without memory-bandwidth throttling.
  • Apple Silicon Metal Acceleration: Directly utilizes torch.mps with hardware synchronization barriers (torch.mps.synchronize()) for consistent throughput measurement.

πŸ“¦ Installation & Setup

Prerequisites

Requirement Supported Versions Verification
macOS 11.0+ (Big Sur to Sequoia) sw_vers
Python 3.10 or 3.11 python3 --version
System Tool smartmontools smartctl --version

Quick Start

# 1. Clone repository
git clone https://github.com/CodeGeekR/macOS-hardware-info.git
cd macOS-hardware-info

# 2. Install system dependency
brew install smartmontools

# 3. Create virtual environment
python3.11 -m venv venv
source venv/bin/activate

# 4. Install Python dependencies
pip install --upgrade pip setuptools wheel
pip install -r requirements.txt

# 5. Run diagnostics suite
sudo python3 macOS-Hardware-info.py

πŸ“„ License & Author

Distributed under the MIT License. See LICENSE for details.

Copyright (c) 2024 samuraidev

Author: samuraidev
Portfolio: arquitectodesoftware.co

⭐ Star this project if you find it useful!

Built with precision for the macOS developer community

Made with Python Apple Silicon PRs Welcome

About

Complete Hardware Diagnostics & AI Performance Suite for macOS (CPU, GPU, NPU, SSD, TBW, AI, TOPS, SMC)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages