|
| 1 | +A simple benchmarking tool. |
| 2 | + |
| 3 | +## Benchmark Python Environment Manual Setup (Windows) |
| 4 | + |
| 5 | +Currently a version of this tool that spawns async workers/coroutines instead of |
| 6 | +concurrent threads is not supported, so if you use a "normal" (non free-threaded) version |
| 7 | +of Python, you will be running with the global interpreter lock (GIL). |
| 8 | + |
| 9 | +Note: This may or may not incur significant changes in performance over using |
| 10 | +free-threaded concurrent tests or async workers, depending on the test scenario. |
| 11 | + |
| 12 | +Install any Python version >= 3.9. Check with: |
| 13 | + |
| 14 | +```bash |
| 15 | +python --version |
| 16 | +``` |
| 17 | + |
| 18 | +Then, set up and activate the virtual environment with: |
| 19 | + |
| 20 | +```bash |
| 21 | +python -m venv venv |
| 22 | +. ./venv/Scripts/activate |
| 23 | +pip install -r requirements.txt |
| 24 | +``` |
| 25 | + |
| 26 | +To activate the virtual environment, use: |
| 27 | + |
| 28 | +```bash |
| 29 | +. ./venv/Scripts/activate |
| 30 | +``` |
| 31 | + |
| 32 | +To deactivate it, you may use: |
| 33 | + |
| 34 | +```bash |
| 35 | +deactivate |
| 36 | +``` |
| 37 | + |
| 38 | +## Benchmark Python Environment Setup (Windows) - Free Threaded Python |
| 39 | + |
| 40 | +Traditionally, most Python versions have a global interpreter lock (GIL) which prevents |
| 41 | +more than 1 thread to run at the same time. With 3.13, there are free-threaded versions |
| 42 | +of Python which allow one to bypass this constraint. This section walks through how |
| 43 | +to do that on Windows. Use PowerShell. |
| 44 | + |
| 45 | +Based on: https://docs.python.org/3/using/windows.html# |
| 46 | + |
| 47 | +Go to `Microsoft Store` and install `Python Install Manager` and follow the instructions |
| 48 | +presented. You may have to make certain changes to alias used by your machine (that |
| 49 | +should be guided by the installation process). |
| 50 | + |
| 51 | +Based on: https://docs.python.org/3/whatsnew/3.13.html#free-threaded-cpython |
| 52 | + |
| 53 | +In PowerShell, install the free-threaded version of Python of your choice. In this guide |
| 54 | +we will install `3.14t`: |
| 55 | + |
| 56 | +```bash |
| 57 | +py install 3.14t |
| 58 | +``` |
| 59 | + |
| 60 | +Then, set up and activate the virtual environment with: |
| 61 | + |
| 62 | +```bash |
| 63 | +python3.14t -m venv venv |
| 64 | +. ./venv/Scripts/activate |
| 65 | +pip install -r requirements.txt |
| 66 | +``` |
| 67 | + |
| 68 | +To activate the virtual environment, use: |
| 69 | + |
| 70 | +```bash |
| 71 | +. ./venv/Scripts/activate |
| 72 | +``` |
| 73 | + |
| 74 | +To deactivate it, you may use: |
| 75 | + |
| 76 | +```bash |
| 77 | +deactivate |
| 78 | +``` |
| 79 | + |
| 80 | +## Benchmark Configuration |
| 81 | + |
| 82 | +If you open the `env.template` file, you will see three environmental variables to define: |
| 83 | + |
| 84 | +```bash |
| 85 | +TENANT_ID= |
| 86 | +APP_ID= |
| 87 | +APP_SECRET= |
| 88 | +``` |
| 89 | + |
| 90 | +For `APP_ID` use the app Id of your ABS resource. For `APP_SECRET` set it to a secret |
| 91 | +for the App Registration resource tied to your ABS resource. Finally, the `TENANT_ID` |
| 92 | +variable should be set to the tenant Id of your ABS resource. |
| 93 | + |
| 94 | +These settings are used to generate valid tokens that are sent and validated by the |
| 95 | +agent you are trying to run. |
| 96 | + |
| 97 | +## Usage |
| 98 | + |
| 99 | +Running these tests requires you to have the agent running in a separate process. You |
| 100 | +may open a separate PowerShell window or VSCode window and run your agent there. |
| 101 | + |
| 102 | +To run the basic payload sending stress test (our only implemented test so far), use: |
| 103 | + |
| 104 | +```bash |
| 105 | +. ./venv/Scripts/activate # activate the virtual environment if you haven't already |
| 106 | +python -m src.main --num_workers=... |
| 107 | +``` |
0 commit comments