Skip to content

Commit

Permalink
Fix benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
BurnySc2 committed Jan 14, 2023
1 parent 05bcfc6 commit 2ee5387
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions test/benchmark_bot_ai_init.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from test.test_pickled_data import MAPS, build_bot_object_from_pickle_data, load_map_pickle_data
from typing import Any, List, Tuple

import pytest


async def _test_run_bot_ai_init_on_all_maps(pickle_data: List[Tuple[Any, Any, Any]]):
for data in pickle_data:
await build_bot_object_from_pickle_data(*data)


@pytest.mark.asyncio
async def test_bench_bot_ai_init(benchmark):
# Load pickle files outside of benchmark
map_pickle_data: List[Tuple[Any, Any, Any]] = [load_map_pickle_data(path) for path in MAPS]
Expand Down
9 changes: 6 additions & 3 deletions test/benchmark_prepare_units.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
from test.test_pickled_data import MAPS, get_map_specific_bot
from typing import TYPE_CHECKING, List

import pytest

if TYPE_CHECKING:
from sc2.bot_ai import BotAI


def _run_prepare_units(bot_objects: List["BotAI"]):
async def _run_prepare_units(bot_objects: List["BotAI"]):
for bot_object in bot_objects:
bot_object._prepare_units()
await bot_object._prepare_units()


def test_bench_prepare_units(benchmark):
@pytest.mark.asyncio
async def test_bench_prepare_units(benchmark):
bot_objects = [get_map_specific_bot(map_) for map_ in MAPS]
_result = benchmark(_run_prepare_units, bot_objects)

Expand Down

0 comments on commit 2ee5387

Please sign in to comment.