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.
- 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.
- A Linux-based operating system. (Planning to make it portable)
- GCC (GNU Compiler Collection) to compile the source code.
-
Clone the repository:
git clone <repository_url> cd <repository_name>
-
Build the tool using the provided
Makefile
:make
This will create the
bentest
executable asbuild/bentest
.Note: Ensure
make
is installed on your system.
Run the tool with the following command:
./build/bentest <num_iterations> <program> [args...]
<num_iterations>
: The number of times to execute the program. Must be a positive integer.<program>
: The program to execute (e.g.,gzip
,curl
,python
scripts, etc.).[args...]
: Additional arguments for the program.
- Compress a file with
gzip
:This runs./build/bentest 3 gzip sample.txt
gzip sample.txt
three times and monitors its performance.
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)
- Argument Parsing: The tool validates the number of iterations and the program to execute.
- Process Creation: Uses
fork()
to create a child process for each execution. - Program Execution: The child process runs the program using
execvp()
. - Timing and Metrics:
- Captures execution time using
clock_gettime
- Collects resource usage data using
getrusage
- Captures execution time using
- Statistics Calculation: Updates and aggregates runtime statistics across iterations.
- Internal commands (e.g.,
cd
,exit
) are not supported directly.
- Add memory usage monitoring.
- Monitor system calls
- Improve the accuracy for total time measurement.
- Portability to non-unix systems.
Contributions are welcome! If you find a bug or want to add a feature:
- Fork the repository.
- Create a new branch.
- Submit a pull request with a detailed description.
This project is licensed under the MIT License.
For any inquiries or feedback, feel free to reach out via GitHub issues.
Happy monitoring! 🚀