-
Notifications
You must be signed in to change notification settings - Fork 0
kcpu.py
This is a Python module (kcpu.py
) that provides functions for simulating high CPU usage. Please note that running these functions can cause your computer to freeze or crash. Use them responsibly and at your own risk.
To use this module, you need to import it into your Python script. Here's an example of how to import and use the kill_cpu1()
and kill_cpu2()
functions:
import time
from kcpu import kill_cpu1, kill_cpu2
# Simulate high CPU usage indefinitely
kill_cpu1() # This function uses time.sleep()
kill_cpu2() # This function uses multiprocessing.Pool().map()
This function uses a while
loop and the time.sleep()
function to simulate high CPU usage. It repeatedly sleeps for a very short duration (0.001 seconds by default) before continuing the loop.
Example usage:
kill_cpu1()
This function uses a while
loop, the multiprocessing.Pool()
class, and the map()
method to simulate high CPU usage. It creates a pool of worker processes and maps the lambda function lambda x: x**x
to a range of values (0 to 999999 by default). This will cause each worker process to calculate x**x
for each value in the range.
Example usage:
kill_cpu2()
Please note that both functions are designed to run indefinitely, and you may need to interrupt the execution manually.
Warning: Running these functions can cause your computer to freeze or crash. Use them responsibly and at your own risk.
To import this module into your Python script or interactive session, use the following import statement:
import kcpu
After importing, you can use the functions kill_cpu1()
and kill_cpu2()
directly by referencing kcpu.kill_cpu1()
and kcpu.kill_cpu2()
respectively.
Remember to install any dependencies required by this module before using it.