How se-fbk/followthepid works
Project type and purpose
• This is an open-source Python library/CLI tool named followThePid.
• Purpose: trace CPU usage and energy consumption of a running process (by PID) on Linux and macOS.
File structure
• Top-level:
• setup.py, requirements.txt → packaging & dependencies
• src/
• Inside src/:
• cpu.py → core CPU‐usage sampling
• device/ → abstraction for platform-specific energy readings
– base.py → abstract interface (DeviceBase)
– factory.py → chooses correct Device implementation at runtime
– linux.py, mac.py, windows.py → OS adapters
• metrics.py → data collection & normalization logic
• followThePid.py → main user-facing class (FollowThePid)
• example/simple_example.py → usage demo
README for additional insights
• Dependencies: Python 3.12+, pandas optional
• Uses Intel RAPL on Linux, powermetrics on macOS
• Outputs: CSV or pandas DataFrame
Elements
• Clear labels: e.g., “FollowThePid (CLI/Library)”, “DeviceFactory”, “LinuxDevice”