CppPerfTrack is a lightweight system profiling and performance tracking CLI tool written in C++. It seamlessly measures execution time, maximum memory footprint, and CPU time of any shell command or script. The results are exported to JSON, which can then be visualized using the included Python dashboard script.
- Accurate Profiling: Leverages
fork/execandgetrusagefor robust process measurement. - Multiple Metrics: Captures Wall-clock duration (ms), Max Memory Usage (KB), and CPU time (ms).
- Extensible Storage: Easily swap or extend the storage layer (currently supports JSON, ready for SQLite).
- Visual Dashboard: Automatically generates beautiful Matplotlib charts from your benchmark runs.
- Lightweight & Fast: Minimal dependencies, pure C++17 core.
CppPerfTrack/
├── CMakeLists.txt # Build configuration
├── include/ # Header files (.hpp)
│ ├── Metric.hpp # Data structures
│ ├── Storage.hpp # Storage interfaces
│ ├── JsonStorage.hpp # JSON implementation
│ └── Profiler.hpp # Core profiling logic
├── src/ # Source files (.cpp)
│ ├── JsonStorage.cpp
│ ├── Profiler.cpp
│ └── main.cpp # CLI Entry point
└── scripts/ # Data visualization utilities
├── dashboard.py
└── requirements.txt
To build and run CppPerfTrack, you will need:
- Compiler with C++17 support (GCC, Clang, or MSVC)
- CMake (v3.10 or higher)
- Python 3.6+ (for the visualization dashboard)
- (Optional) Unix-like system (Linux/macOS) for
getrusagesupport.
Build the C++ CLI tool:
# 1. Clone the repository
git clone https://github.com/your-username/CppPerfTrack.git
cd CppPerfTrack
# 2. Configure with CMake and build
mkdir build && cd build
cmake ..
makeInstall Python dependencies for the dashboard:
cd ..
pip install -r scripts/requirements.txtRun the executable and pass a custom label along with the command you want to profile.
cd build
./CppPerfTrack "List Files" "ls -la"
./CppPerfTrack "Heavy Math Script" "python ../scripts/heavy_math.py"This will automatically generate a metrics.json file in your current directory containing the profiling data.
Once you have gathered some metrics, generate a visual report:
python scripts/dashboard.py --input build/metrics.jsonA file named report.png will be created, containing side-by-side bar charts of Execution Time (ms) and Max Memory Usage (KB).
metrics.json
[
{
"name": "List Files",
"duration_ms": 12.45,
"memory_kb": 3216,
"cpu_time_ms": 2.1,
"timestamp": "2025-10-15 10:15:30"
}
]Contributions are welcome!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.