https://github.com/marob05/bentest
basic performance measurement tool written in C with various statistical measures
https://github.com/marob05/bentest
cprogramming linux profiling runtime unix
Last synced: about 1 month ago
JSON representation
basic performance measurement tool written in C with various statistical measures
- Host: GitHub
- URL: https://github.com/marob05/bentest
- Owner: MaroB05
- Created: 2025-01-08T02:52:26.000Z (5 months ago)
- Default Branch: master
- Last Pushed: 2025-01-29T14:44:57.000Z (4 months ago)
- Last Synced: 2025-03-29T03:26:42.457Z (about 2 months ago)
- Topics: cprogramming, linux, profiling, runtime, unix
- Language: C
- Homepage:
- Size: 2.3 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Bentest
`Bentest` is a **Performance Monitoring Tool** written in C. It measures runtime statistics of a given program.
It repeatedly executes the specified program, collects metrics like execution time, CPU usage, and voluntary context switches, and outputs performance summaries to help identify potential inefficiencies.
Think of it as Linux's `time` on steroids.Currently supporting unix-based systems and planned to support windows soon.
## Features- Executes a program multiple times and measures:
- User time
- System time
- Total execution time
- CPU usage
- Voluntary context switches
- Involuntary context switches
- Page Faults (soft and hard)
- File System I/O (input and output) blocks
- Uses `getrusage` for high-accuracy CPU time measurement.
- Accepts command-line arguments for flexibility.
- Outputs statistics to help analyze program performance.## Requirements
- A Linux-based operating system. (Planning to make it portable)
- GCC (GNU Compiler Collection) to compile the source code.## Installation
1. Clone the repository:
```bash
git clone
cd
```2. Build the tool using the provided `Makefile`:
```bash
make
```This will create the `bentest` executable as `build/bentest`.
> **Note**: Ensure `make` is installed on your system.
## Usage
Run the tool with the following command:
```bash
./build/bentest [args...]
```### Arguments:
- ``: The number of times to execute the program. Must be a positive integer.
- ``: The program to execute (e.g., `gzip`, `curl`, `python` scripts, etc.).
- `[args...]`: Additional arguments for the program.### Examples:
1. **Compress a file with `gzip`:**
```bash
./build/bentest 3 gzip sample.txt
```
This runs `gzip sample.txt` three times and monitors its performance.## Output
The program outputs statistics for each run and a summary of:
- User time
- System time
- Total execution time
- CPU usage percentage
- Voluntary context switches (indicating potential system call frequency)## How It Works
1. **Argument Parsing**: The tool validates the number of iterations and the program to execute.
2. **Process Creation**: Uses `fork()` to create a child process for each execution.
3. **Program Execution**: The child process runs the program using `execvp()`.
4. **Timing and Metrics**:
- Captures execution time using `clock_gettime`
- Collects resource usage data using `getrusage`
5. **Statistics Calculation**: Updates and aggregates runtime statistics across iterations.## Limitations
- Internal commands (e.g., `cd`, `exit`) are not supported directly.## Future Enhancements
- Add memory usage monitoring.
- Monitor system calls
- Improve the accuracy for total time measurement.
- Portability to non-unix systems.## Contributing
Contributions are welcome! If you find a bug or want to add a feature:
1. Fork the repository.
2. Create a new branch.
3. Submit a pull request with a detailed description.## License
This project is licensed under the [MIT License](LICENSE).---
### Contact
For any inquiries or feedback, feel free to reach out via GitHub issues.---
Happy monitoring! :rocket: