forked from lorserker/ben
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from Seven-of-Di/develop
chore: Develop
- Loading branch information
Showing
25 changed files
with
681 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"hand": "KT7.9.KT643.875", | ||
"dummy_hand": ".AJ754.A52.AQ94", | ||
"dealer": "S", | ||
"vuln": "E-W", | ||
"contract": "3N", | ||
"contract_direction": "S", | ||
"auction": [ | ||
"PASS", | ||
"PASS", | ||
"1H", | ||
"PASS", | ||
"1S", | ||
"PASS", | ||
"2C", | ||
"PASS", | ||
"2N", | ||
"PASS", | ||
"3N", | ||
"PASS", | ||
"PASS", | ||
"PASS" | ||
], | ||
"next_player": "W", | ||
"tricks": [["SJ", "S3", "S2", "S4"]] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"hand": "Q82.KQ863.9.JT63", | ||
"dummy_hand": "65.AJ75.AQ.AQ94", | ||
"dealer": "S", | ||
"vuln": "E-W", | ||
"contract": "3N", | ||
"contract_direction": "S", | ||
"auction": [ | ||
"PASS", | ||
"PASS", | ||
"1H", | ||
"PASS", | ||
"1S", | ||
"PASS", | ||
"2C", | ||
"PASS", | ||
"2N", | ||
"PASS", | ||
"3N", | ||
"PASS", | ||
"PASS", | ||
"PASS" | ||
], | ||
"next_player": "E", | ||
"tricks": [ | ||
[ | ||
"SJ", | ||
"C2" | ||
] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
## Loadtesting tool for Robot API ## | ||
|
||
### How to use ### | ||
1. Install dependency using [poetry](https://github.com/python-poetry/poetry). | ||
```sh | ||
$ poetry install | ||
``` | ||
|
||
2. Help | ||
```sh | ||
$ python loadtest/command.py --help | ||
``` |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import click | ||
from play_card import PlayCardTest | ||
|
||
@click.command() | ||
@click.option('--threads', default=1, help='Number of parallel threads to run the load from', type=int) | ||
@click.option('--count', help='Total count of requests to make', type=int) | ||
@click.option('--url', help='The URL to execute the test agaist') | ||
def play_card(threads, count, url): | ||
PlayCardTest(threads=threads, count=count, url=url).execute() | ||
|
||
if __name__ == '__main__': | ||
play_card() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import concurrent | ||
from concurrent.futures import ThreadPoolExecutor | ||
import time | ||
import requests | ||
import json | ||
|
||
class PlayCardTest: | ||
def __init__(self, threads, count, url) -> None: | ||
self.threads = threads | ||
self.count = count | ||
self.url = url | ||
|
||
def execute(self): | ||
completion_times = [] | ||
|
||
with ThreadPoolExecutor(max_workers=self.threads) as executor: | ||
futures = [executor.submit(send_request, self.url, json_data) for i in range(self.count)] | ||
|
||
for future in concurrent.futures.as_completed(futures): | ||
data = future.result() | ||
completion_times.append(data) | ||
|
||
executor.shutdown() | ||
|
||
average_request_time = round(sum(completion_times) / len(completion_times), 2) | ||
|
||
print('Took {} seconds in average per request to complete'.format(average_request_time)) | ||
|
||
|
||
def send_request(url, json_data) -> float: | ||
start = time.time() | ||
res = requests.post('{}/play_card'.format(url), json=json_data) | ||
|
||
return time.time()-start | ||
|
||
json_data = { | ||
"hand": "KT7.9.KT643.875", | ||
"dummy_hand": ".AJ754.A52.AQ94", | ||
"dealer": "S", | ||
"vuln": "E-W", | ||
"contract": "3NS", | ||
"contract_direction": "S", | ||
"auction": [ | ||
"PASS", | ||
"PASS", | ||
"1H", | ||
"PASS", | ||
"1S", | ||
"PASS", | ||
"2C", | ||
"PASS", | ||
"2H", | ||
"PASS", | ||
"3H", | ||
"PASS", | ||
"3N", | ||
"PASS", | ||
"PASS", | ||
"PASS" | ||
], | ||
"next_player": "W", | ||
"tricks": [ | ||
[ | ||
"SJ", | ||
"S3", | ||
"S2", | ||
"S4" | ||
] | ||
] | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[tool.poetry] | ||
name = "loadtest" | ||
version = "0.1.0" | ||
description = "" | ||
authors = ["Zhivko Draganov <[email protected]>"] | ||
readme = "README.md" | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.8" | ||
click = "^8.1.3" | ||
requests = "^2.28.2" | ||
|
||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,38 @@ | ||
tensorflow==2.11.0 | ||
aiofiles==23.1.0 | ||
asgiref==3.6.0 | ||
blinker==1.6.2 | ||
certifi==2022.12.7 | ||
click==8.1.3 | ||
Deprecated==1.2.13 | ||
h11==0.14.0 | ||
h2==4.1.0 | ||
hpack==4.0.0 | ||
hypercorn==0.14.3 | ||
hyperframe==6.0.1 | ||
importlib-metadata==6.0.1 | ||
itsdangerous==2.1.2 | ||
Jinja2==3.1.2 | ||
MarkupSafe==2.1.2 | ||
opentelemetry-api==1.17.0 | ||
opentelemetry-sdk==1.17.0 | ||
opentelemetry-exporter-otlp-proto-grpc==1.17.0 | ||
opentelemetry-instrumentation==0.38b0 | ||
opentelemetry-instrumentation-asgi==0.38b0 | ||
opentelemetry-semantic-conventions==0.38b0 | ||
opentelemetry-util-http==0.38b0 | ||
pickle5==0.0.11 | ||
priority==2.0.0 | ||
protobuf==3.19.0 | ||
psutil==5.9.4 | ||
quart==0.18.3 | ||
hypercorn==0.14.3 | ||
sentry-sdk==1.16.0 | ||
psutil==5.9.4 | ||
sqlitedict==2.1.0 | ||
pickle5==0.0.11 | ||
tensorflow==2.11.0 | ||
toml==0.10.2 | ||
typing_extensions==4.5.0 | ||
urllib3==1.26.15 | ||
Werkzeug==2.2.3 | ||
wrapt==1.15.0 | ||
wsproto==1.2.0 | ||
zipp==3.15.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"card": "S4", | ||
"claim_the_rest": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.