Metadata-Version: 2.4
Name: stresstify
Version: 0.1.1
Summary: stresstify is a Python package designed for retrieving system information and performing stress tests on CPU, RAM, and disk. It provides detailed CPU information, including name, core count, frequency, and usage, as well as memory and disk usage statistics. The package includes stress tests such as CPU-intensive calculations across multiple cores, continuous RAM allocation until failure, and disk write speed measurement. The author is not responsible for any hardware damage caused by excessive load.
Author-email: Pinkysha <pinny228q@gmail.com>
License: MIT License
        
        Copyright (c) [year] [fullname]
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: psutil>=5.9.0
Requires-Dist: numpy>=1.24.0
Requires-Dist: py-cpuinfo>=9.0.0
Requires-Dist: plotext>=5.3.2
Requires-Dist: matplotlib>=3.10.1
Dynamic: license-file

# Stresstify

Stresstify is a Python module created specifically for stress testing of CPU, RAM, and disk. It also provides tools to monitor the state of these components.

The module includes the main `StressTest` class with several methods, as well as additional standalone functions.


The command to install the module is `pip install stresstify`
***

### RAM Test
The `ram_test()` method performs a simple stress test on the system's RAM by loading files of approximately 8 MB into memory. When using `debug=True`, it records the elapsed time and memory usage percentage for each iteration. The `size` parameter defines how many MB will be added per iteration, with a default value of 8.

``` python
import stresstify
root = stresstify.StressTest(debug=True)
result = root.ram_test()
print(result)
```
Output:
``` python
{'elapsed_time': 32, 'ram_used': {0.03: '59.80%', 0.05: '60.00%', 0.07: '60.10%', 0.09: '60.30%', 0.10: '100%'}}
```
***
### Memory Test
The `memory_test()` method checks the disk write and read speeds by creating a temporary 1 GB binary file, which is immediately deleted. With `debug=True`, it displays the average write speed and average write time; with `debug=False`, it outputs only the values from the last iteration. Below are the key values in the dictionary and their meanings:
* `average_write_time`: Average time taken to write the data in seconds.
* `average_read_speed`: Average read speed in MB/s.
* `read_average_time`: Average time taken to read the data in seconds.
``` python
import stresstify
root = stresstify.StressTest(debug=True)
result = root.memory_test()
print(result)
```
Output:
``` python
{'average_speed': 1189.33, 'average_time': 0.86}
```
***
### CPU Test 
The cpu_test() function creates a high CPU load by multiplying large matrices on each other. By default, the parameter size=11585, which is equal to about 1 gb of data for multiplications, also by default iterations=11, which means that the processor will perform 10 such tasks, which will be divided to all processor cores automatically. When you output the result of the function, you will see a dictionary with the contents:

* `average_cpu_load`: Average CPU load.
* `average_cpu_freq`: Average CPU frequency.
* `cpu_load_dict`: A dictionary with the key "start" representing the initial CPU load, followed by the load for each iteration.
* `cpu_freq_dict`: A dictionary with the key "start" representing the initial CPU frequency, followed by the frequency for each iteration.
* `time_dict`: The elapsed time for each iteration. (Note: The time values might not strictly increase, as different cores may complete tasks at varying speeds.)
Parameters: 
* `size`: Data capacity (default is 1 GB).
* `iterations`: Number of iterations for the load (distributed to all processor cores).
* `debug`: Default is False, but when set to True, provides additional information during function execution.
* `visualize`: Default is False. If set to True, it displays plots (works with `debug=True`).
* `x_label`: Optional parameter to add text to the x-axis of the plot.
* `y_label`: Optional parameter to add text to the y-axis of the plot.
* `title`: Optional parameter to add a title to the chart.
* `plot_type`: If `plot_type="window"`, it will open a window with the chart. If `plot_type="console"`, it will display the chart in the console.
``` python
import stresstify
if __name__ == '__main__':
    root = stresstify.StressTest(debug=True)
    result = root.cpu_test()
    print(result)
```
Output:
``` python
{'average_cpu_load': 23.37, 'average_cpu_freq': 2409.09, 'average_time': 25.74, 'cpu_load_dict': {'start': 3.1, 1: 23.8, 2: 23.3, 3: 34.6, 4: 33.1, 5: 22.4, 6: 22.5, 7: 27.8, 8: 21.9, 9: 22.2, 10: 22.4}, 'cpu_freq_dict': {'start': 2500.0, 1: 2500.0, 2: 2500.0, 3: 2500.0, 4: 2500.0, 5: 2500.0, 6: 1500.0, 7: 2500.0, 8: 2500.0, 9: 2500.0, 10: 2500.0}, 'time_dict': {1: 25.84, 2: 25.91, 3: 25.44, 4: 25.41, 5: 26.0, 6: 25.82, 7: 25.43, 8: 25.95, 9: 25.88, 10: 25.69}}
```
***
### CPU Info
The standalone function `cpu_info()` provides detailed information about the processor:
* `cpu_name`: The name of the processor.
* `physical_cores`: Number of physical cores.
* `logical_cores`: Number of logical cores.
* `max_frequency`: Maximum CPU frequency.
* `min_frequency`: Minimum CPU frequency.
* `current_frequency`: Current CPU frequency.
* `cpu_percent`: A list showing the load percentage for each core.
``` python
import stresstify
root = stresstify.cpu_info()
print(root)
```
Output:
``` python
{'cpu_name': '12th Gen Intel(R) Core(TM) i5-12450H', 'physical_cores': 8, 'logical_cores': 12, 'max_frequency': 2500.0, 'min_frequency': 0.0, 'current_frequency': 1500.0, 'cpu_percent': [9.1, 47.8, 22.2, 13.8, 23.8, 13.6, 25.4, 13.6, 15.2, 15.6, 16.7, 16.4]}
```
***
### RAM Info
The `memory_info()` function retrieves details about the system's RAM:
* `Total_GB`: Total RAM in gigabytes.
* `Used_GB`: Amount of RAM currently used (in gigabytes).
* `Free_GB`: Amount of free RAM (in gigabytes).
* `Percent`: Percentage of RAM utilization.
``` python
import stresstify
root = stresstify.memory_info()
print(root)
```
Output:
``` python
{'Total_GB': 15.710990905761719, 'Used_GB': 10.429752349853516, 'Free_GB': 5.280986785888672, 'Percent': 66.4}
```
***
### Disk Info
The `disk_info()` function displays information about each disk partition. For each partition, it provides:
* `mountpoint`: The path where the partition is mounted (e.g., "C:\", "/mnt/data").
* `total_size_GB`: Total size of the partition in gigabytes.
* `used_size_GB`: Used space on the partition in gigabytes.
* `free_size_GB`: Free space on the partition in gigabytes.
* `usage_percent`: Percentage of the partition's used space.
``` python
import stresstify
root = stresstify.disk_info()
print(root)
```
Output:
``` python
{'C:\\': {'mountpoint': 'C:\\', 'total_size_GB': 181.64, 'used_size_GB': 157.15, 'free_size_GB': 24.49, 'usage_percent': 86.5}, 'D:\\': {'mountpoint': 'D:\\', 'total_size_GB': 214.45, 'used_size_GB': 168.92, 'free_size_GB': 45.53, 'usage_percent': 78.8}, 'E:\\': {'mountpoint': 'E:\\', 'total_size_GB': 80.0, 'used_size_GB': 16.71, 'free_size_GB': 63.29, 'usage_percent': 20.9}}
```
***
### Plot
The `plot()` method is used for quickly creating plots that can be displayed in the console or opened in a separate window. The method supports a couple of parameters:

`x`: This parameter accepts ONLY a list with float elements inside. It is used for the x-coordinate values.
`y`: This parameter accepts ONLY a list with float elements inside. It is used for the y-coordinate values.
`x_label`: Label for the x-axis.
`y_label`: Label for the y-axis.
`title`: Title label.
`type`: This parameter accepts `console` and `window`. When set to `console`, the program will display the plot in the console, and when set to `window`, it will open a window with the plot.
``` python
import stresstify
if __name__ == '__main__':
    root = stresstify.StressTest(debug=True)
    result = root.cpu_test(iterations=8)
    x = list(result['time_dict'].keys())
    y = list(result['cpu_load_dict'].values())[1:]
    stresstify.plot(x, y, x_label='Time', y_label='CPU %', title='CPU Test', type='window') # or type='console'
```
Output:
![plot](https://i.ibb.co/RGThnSDk/Figure-1.png)
or
```
                                      CPU Test                                  
    ┌──────────────────────────────────────────────────────────────────────────┐
38.5┤        *                                                                 │
    │       **                                                                 │
    │       **                                                                 │
34.9┤      *  *                                                                │
    │      *  *                                                                │
    │     *    *                                                               │
31.3┤     *    *                                                               │
    │    *      *                                                              │
27.6┤    *      *                                                              │
    │   *        *                                                             │
    │   *        *                                                             │
24.0┤  *          *                                                            │
    │  *          *                                                            │
    │ *            *                                                           │
20.4┤ *            *                                                           │
    │*              *                                                          │
    │*              *        *                                        *        │
16.8┤                ******** **************************************** ********│
    └┬─────────────────┬──────────────────┬─────────────────┬─────────────────┬┘
    1.0               3.2                5.5               7.8             10.0 
CPU %                                   Time                                    
```

***
### [Project Source Code](https://github.com/Pinkysha228/stresstify)
