Skip to content

Commit

Permalink
Moved benchmark testing to a seperate test
Browse files Browse the repository at this point in the history
  • Loading branch information
CalShucha committed Jan 14, 2025
1 parent 828cc06 commit c983a33
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 14 deletions.
26 changes: 24 additions & 2 deletions taf/tests/test_benchmark_testing.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import time
import pytest
import pytest_benchmark
import random

def test_benchmark(benchmark):
benchmark(time.sleep, 0.6)
benchmark(get_useless_number)
#benchmark(time.sleep, 0.6)

def test_concurrency_with_file_writing(benchmark):
benchmark(write_numbered_lines)


def test_benchmark_two(benchmark):
Expand All @@ -12,4 +17,21 @@ def test_benchmark_two(benchmark):

def function_test():
time.sleep(0.1)
assert False
#assert False


def write_numbered_lines():
for i in range(2):
with open("C:\\Users\\doxie\\OneDrive\\Desktop\\TestOutput.txt", 'a') as the_file:
the_file.write(f"Line {i}\n")
the_file.close()
time.sleep(random.random() / 1000)

def get_useless_number():
try:
x = 3
return x
finally:
time.sleep(0.5)
y = 4
z = 3
25 changes: 13 additions & 12 deletions taf/tests/test_updater/test_clone/test_clone_valid.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,24 @@
],
indirect=True,
)
def test_clone_valid_happy_path(origin_auth_repo, client_dir, benchmark):
def test_clone_valid_happy_path(origin_auth_repo, client_dir):
setup_manager = SetupManager(origin_auth_repo)
setup_manager.add_task(add_valid_target_commits)
setup_manager.execute_tasks()

def clone_valid_happy_path_inner(origin_auth_repo, client_dir):
is_test_repo = origin_auth_repo.is_test_repo
expected_repo_type = UpdateType.TEST if is_test_repo else UpdateType.OFFICIAL
update_and_check_commit_shas(
OperationType.CLONE,
origin_auth_repo,
client_dir,
expected_repo_type=expected_repo_type,
)
cleanup_directory(client_dir)

benchmark(clone_valid_happy_path_inner, origin_auth_repo, client_dir)
# def clone_valid_happy_path_inner(origin_auth_repo, client_dir):
is_test_repo = origin_auth_repo.is_test_repo
expected_repo_type = UpdateType.TEST if is_test_repo else UpdateType.OFFICIAL
update_and_check_commit_shas(
OperationType.CLONE,
origin_auth_repo,
client_dir,
expected_repo_type=expected_repo_type,
)
cleanup_directory(client_dir)

# benchmark(clone_valid_happy_path_inner, origin_auth_repo, client_dir)


@pytest.mark.parametrize(
Expand Down
19 changes: 19 additions & 0 deletions taf/tests/test_updater/test_update_benchmarking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import pytest
from taf.tests.test_updater.test_clone.test_clone_valid import test_clone_valid_happy_path


@pytest.mark.parametrize(
"origin_auth_repo",
[
{
"targets_config": [{"name": "target1"}, {"name": "target2"}],
},
{
"is_test_repo": True,
"targets_config": [{"name": "target1"}, {"name": "target2"}],
},
],
indirect=True,
)
def test_benchmark_clone_valid_happy_path(origin_auth_repo, client_dir, benchmark):
benchmark(test_clone_valid_happy_path, origin_auth_repo, client_dir)

0 comments on commit c983a33

Please sign in to comment.