Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding simple benchmark #115

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions benchmarks/benchmarks/brainglobe_atlasapi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import json
import os
from pathlib import Path

from brainglobe_workflows.brainglobe_atlasapi.create_mouse_atlas import (
create_mouse_atlas,
)


class TimeBenchmark:
# Timing attributes
timeout = 3600 # default: 60 s

def setup(self):
# read input config: environment variable if it exists, else default
input_config_path = os.getenv(
"ATLAS_CONFIG_PATH",
default=str(
Path(__file__).parents[2]
/ "brainglobe_workflows"
/ "configs"
/ "brainglobe_atlasapi_small.json"
),
)

assert Path(input_config_path).exists()

# read as dict
with open(input_config_path) as cfg:
config_dict = json.load(cfg)

# pass dict to class
self.config = config_dict

def time_create_mouse_atlas(self):
create_mouse_atlas(**self.config)
Empty file.
10 changes: 10 additions & 0 deletions brainglobe_workflows/brainglobe_atlasapi/create_mouse_atlas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from brainglobe_atlasapi import BrainGlobeAtlas

Check warning on line 1 in brainglobe_workflows/brainglobe_atlasapi/create_mouse_atlas.py

View check run for this annotation

Codecov / codecov/patch

brainglobe_workflows/brainglobe_atlasapi/create_mouse_atlas.py#L1

Added line #L1 was not covered by tests


def create_mouse_atlas(atlas_name):
atlas = BrainGlobeAtlas(atlas_name)
print(atlas.atlas_name)

Check warning on line 6 in brainglobe_workflows/brainglobe_atlasapi/create_mouse_atlas.py

View check run for this annotation

Codecov / codecov/patch

brainglobe_workflows/brainglobe_atlasapi/create_mouse_atlas.py#L4-L6

Added lines #L4 - L6 were not covered by tests


if __name__ == "__main__":
create_mouse_atlas("allen_mouse_100um")

Check warning on line 10 in brainglobe_workflows/brainglobe_atlasapi/create_mouse_atlas.py

View check run for this annotation

Codecov / codecov/patch

brainglobe_workflows/brainglobe_atlasapi/create_mouse_atlas.py#L9-L10

Added lines #L9 - L10 were not covered by tests
3 changes: 3 additions & 0 deletions brainglobe_workflows/configs/brainglobe_atlasapi_large.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"atlas_name": "allen_mouse_10um"
}
3 changes: 3 additions & 0 deletions brainglobe_workflows/configs/brainglobe_atlasapi_small.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"atlas_name": "allen_mouse_100um"
}
Loading