Compare commits
7 Commits
main
...
alek/bench
Author | SHA1 | Date | |
---|---|---|---|
![]() |
7bff844217 | ||
![]() |
b41f3de720 | ||
![]() |
3b137bded7 | ||
![]() |
3c88dcd905 | ||
![]() |
64e256f2cc | ||
![]() |
6deefe8fd9 | ||
![]() |
3c134cdeee |
1037
.codspeed/results_1737338906383.json
Normal file
1037
.codspeed/results_1737338906383.json
Normal file
File diff suppressed because it is too large
Load Diff
1143
.codspeed/results_1737339049018.json
Normal file
1143
.codspeed/results_1737339049018.json
Normal file
File diff suppressed because it is too large
Load Diff
1143
.codspeed/results_1737339073664.json
Normal file
1143
.codspeed/results_1737339073664.json
Normal file
File diff suppressed because it is too large
Load Diff
1143
.codspeed/results_1737339094692.json
Normal file
1143
.codspeed/results_1737339094692.json
Normal file
File diff suppressed because it is too large
Load Diff
1143
.codspeed/results_1737339206717.json
Normal file
1143
.codspeed/results_1737339206717.json
Normal file
File diff suppressed because it is too large
Load Diff
1143
.codspeed/results_1737339242040.json
Normal file
1143
.codspeed/results_1737339242040.json
Normal file
File diff suppressed because it is too large
Load Diff
1143
.codspeed/results_1737339334189.json
Normal file
1143
.codspeed/results_1737339334189.json
Normal file
File diff suppressed because it is too large
Load Diff
1143
.codspeed/results_1737339367654.json
Normal file
1143
.codspeed/results_1737339367654.json
Normal file
File diff suppressed because it is too large
Load Diff
44
.github/workflows/unit_tests.yml
vendored
44
.github/workflows/unit_tests.yml
vendored
@ -68,21 +68,30 @@ jobs:
|
||||
run-poetry-install: true
|
||||
create-venv-at-path: .venv
|
||||
- name: Run unit tests
|
||||
run: |
|
||||
export PYTHONUNBUFFERED=1
|
||||
poetry run pytest tests/units --cov --no-cov-on-fail --cov-report=
|
||||
uses: CodSpeedHQ/action@v3
|
||||
with:
|
||||
token: ${{ secrets.CODSPEED_TOKEN }}
|
||||
run: |
|
||||
export PYTHONUNBUFFERED=1
|
||||
poetry run pytest tests/units --cov --no-cov-on-fail --codspeed --cov-report= --cov-fail-under=40
|
||||
- name: Run unit tests w/ redis
|
||||
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||
run: |
|
||||
export PYTHONUNBUFFERED=1
|
||||
export REDIS_URL=redis://localhost:6379
|
||||
poetry run pytest tests/units --cov --no-cov-on-fail --cov-report=
|
||||
uses: CodSpeedHQ/action@v3
|
||||
with:
|
||||
token: ${{ secrets.CODSPEED_TOKEN }}
|
||||
run: |
|
||||
export PYTHONUNBUFFERED=1
|
||||
export REDIS_URL=redis://localhost:6379
|
||||
poetry run pytest tests/units --cov --no-cov-on-fail --codspeed --cov-report= --cov-fail-under=40
|
||||
# Change to explicitly install v1 when reflex-hosting-cli is compatible with v2
|
||||
- name: Run unit tests w/ pydantic v1
|
||||
run: |
|
||||
export PYTHONUNBUFFERED=1
|
||||
poetry run uv pip install "pydantic~=1.10"
|
||||
poetry run pytest tests/units --cov --no-cov-on-fail --cov-report=
|
||||
uses: CodSpeedHQ/action@v3
|
||||
with:
|
||||
token: ${{ secrets.CODSPEED_TOKEN }}
|
||||
run: |
|
||||
export PYTHONUNBUFFERED=1
|
||||
poetry run uv pip install "pydantic~=1.10"
|
||||
poetry run pytest tests/units --cov --no-cov-on-fail --codspeed --cov-report= --cov-fail-under=40
|
||||
- name: Generate coverage report
|
||||
run: poetry run coverage html
|
||||
|
||||
@ -105,9 +114,12 @@ jobs:
|
||||
- name: Run unit tests
|
||||
run: |
|
||||
export PYTHONUNBUFFERED=1
|
||||
poetry run pytest tests/units --cov --no-cov-on-fail --cov-report=
|
||||
poetry run pytest tests/units --cov --no-cov-on-fail --cov-report= --cov-fail-under=40
|
||||
- name: Run unit tests w/ pydantic v1
|
||||
run: |
|
||||
export PYTHONUNBUFFERED=1
|
||||
poetry run uv pip install "pydantic~=1.10"
|
||||
poetry run pytest tests/units --cov --no-cov-on-fail --cov-report=
|
||||
uses: CodSpeedHQ/action@v3
|
||||
with:
|
||||
token: ${{ secrets.CODSPEED_TOKEN }}
|
||||
run: |
|
||||
export PYTHONUNBUFFERED=1
|
||||
poetry run uv pip install "pydantic~=1.10"
|
||||
poetry run pytest tests/units --cov --no-cov-on-fail --cov-report= --cov-fail-under=40
|
||||
|
@ -142,6 +142,6 @@ def main():
|
||||
pr_id=args.pr_id,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
@ -7,8 +7,6 @@ import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from utils import send_data_to_posthog
|
||||
|
||||
|
||||
def extract_stats_from_json(json_file: str) -> dict:
|
||||
"""Extracts the stats from the JSON data and returns them as dictionaries.
|
||||
@ -66,9 +64,6 @@ def insert_benchmarking_data(
|
||||
"app_name": app_name,
|
||||
}
|
||||
|
||||
send_data_to_posthog("import_benchmark", properties)
|
||||
|
||||
|
||||
def main():
|
||||
"""Runs the benchmarks and inserts the results."""
|
||||
# Get the commit SHA and JSON directory from the command line arguments
|
||||
|
35
poetry.lock
generated
35
poetry.lock
generated
@ -1147,6 +1147,7 @@ files = [
|
||||
{file = "nh3-0.2.19-cp38-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:00810cd5275f5c3f44b9eb0e521d1a841ee2f8023622de39ffc7d88bd533d8e0"},
|
||||
{file = "nh3-0.2.19-cp38-abi3-win32.whl", hash = "sha256:7e98621856b0a911c21faa5eef8f8ea3e691526c2433f9afc2be713cb6fbdb48"},
|
||||
{file = "nh3-0.2.19-cp38-abi3-win_amd64.whl", hash = "sha256:75c7cafb840f24430b009f7368945cb5ca88b2b54bb384ebfba495f16bc9c121"},
|
||||
{file = "nh3-0.2.19.tar.gz", hash = "sha256:790056b54c068ff8dceb443eaefb696b84beff58cca6c07afd754d17692a4804"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1942,6 +1943,38 @@ aspect = ["aspectlib"]
|
||||
elasticsearch = ["elasticsearch"]
|
||||
histogram = ["pygal", "pygaljs", "setuptools"]
|
||||
|
||||
[[package]]
|
||||
name = "pytest-codspeed"
|
||||
version = "3.1.2"
|
||||
description = "Pytest plugin to create CodSpeed benchmarks"
|
||||
optional = false
|
||||
python-versions = ">=3.9"
|
||||
files = [
|
||||
{file = "pytest_codspeed-3.1.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:aed496f873670ce0ea8f980a7c1a2c6a08f415e0ebdf207bf651b2d922103374"},
|
||||
{file = "pytest_codspeed-3.1.2-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ee45b0b763f6b5fa5d74c7b91d694a9615561c428b320383660672f4471756e3"},
|
||||
{file = "pytest_codspeed-3.1.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c84e591a7a0f67d45e2dc9fd05b276971a3aabcab7478fe43363ebefec1358f4"},
|
||||
{file = "pytest_codspeed-3.1.2-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c6ae6d094247156407770e6b517af70b98862dd59a3c31034aede11d5f71c32c"},
|
||||
{file = "pytest_codspeed-3.1.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:d0f264991de5b5cdc118b96fc671386cca3f0f34e411482939bf2459dc599097"},
|
||||
{file = "pytest_codspeed-3.1.2-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c0695a4bcd5ff04e8379124dba5d9795ea5e0cadf38be7a0406432fc1467b555"},
|
||||
{file = "pytest_codspeed-3.1.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6dc356c8dcaaa883af83310f397ac06c96fac9b8a1146e303d4b374b2cb46a18"},
|
||||
{file = "pytest_codspeed-3.1.2-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:cc8a5d0366322a75cf562f7d8d672d28c1cf6948695c4dddca50331e08f6b3d5"},
|
||||
{file = "pytest_codspeed-3.1.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6c5fe7a19b72f54f217480b3b527102579547b1de9fe3acd9e66cb4629ff46c8"},
|
||||
{file = "pytest_codspeed-3.1.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b67205755a665593f6521a98317d02a9d07d6fdc593f6634de2c94dea47a3055"},
|
||||
{file = "pytest_codspeed-3.1.2-py3-none-any.whl", hash = "sha256:5e7ed0315e33496c5c07dba262b50303b8d0bc4c3d10bf1d422a41e70783f1cb"},
|
||||
{file = "pytest_codspeed-3.1.2.tar.gz", hash = "sha256:09c1733af3aab35e94a621aa510f2d2114f65591e6f644c42ca3f67547edad4b"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
cffi = ">=1.17.1"
|
||||
importlib-metadata = {version = ">=8.5.0", markers = "python_version < \"3.10\""}
|
||||
pytest = ">=3.8"
|
||||
rich = ">=13.8.1"
|
||||
|
||||
[package.extras]
|
||||
compat = ["pytest-benchmark (>=5.0.0,<5.1.0)", "pytest-xdist (>=3.6.1,<3.7.0)"]
|
||||
lint = ["mypy (>=1.11.2,<1.12.0)", "ruff (>=0.6.5,<0.7.0)"]
|
||||
test = ["pytest (>=7.0,<8.0)", "pytest-cov (>=4.0.0,<4.1.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "pytest-cov"
|
||||
version = "6.0.0"
|
||||
@ -3076,4 +3109,4 @@ type = ["pytest-mypy"]
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.9"
|
||||
content-hash = "d62cd1897d8f73e9aad9e907beb82be509dc5e33d8f37b36ebf26ad1f3075a9f"
|
||||
content-hash = "b0b0958d1531c877f5920559cb46caf9118a059c77094853aad9fd817a3d1dbc"
|
||||
|
@ -72,6 +72,7 @@ selenium = ">=4.11.0,<5.0"
|
||||
pytest-benchmark = ">=4.0.0,<6.0"
|
||||
playwright = ">=1.46.0"
|
||||
pytest-playwright = ">=0.5.1"
|
||||
pytest-codspeed = "^3.1.2"
|
||||
|
||||
[tool.poetry.scripts]
|
||||
reflex = "reflex.reflex:cli"
|
||||
|
19
test_benchmark_imports.py
Normal file
19
test_benchmark_imports.py
Normal file
@ -0,0 +1,19 @@
|
||||
import pytest
|
||||
from benchmarks.benchmark_imports import extract_stats_from_json
|
||||
|
||||
@pytest.mark.benchmark
|
||||
def test_extract_stats_from_json(benchmark):
|
||||
# Example JSON data
|
||||
json_data = '{"results": [{"mean": 1.0, "stddev": 0.1, "median": 1.0, "min": 0.9, "max": 1.1}]}'
|
||||
|
||||
# Benchmark the extract_stats_from_json function
|
||||
result = benchmark(extract_stats_from_json, json_data)
|
||||
|
||||
# Assert the result to ensure correctness
|
||||
assert result == {
|
||||
"mean": 1.0,
|
||||
"stddev": 0.1,
|
||||
"median": 1.0,
|
||||
"min": 0.9,
|
||||
"max": 1.1
|
||||
}
|
Loading…
Reference in New Issue
Block a user