|
12 | 12 | from pathlib import Path |
13 | 13 |
|
14 | 14 | import mne |
15 | | -import numpy as np |
16 | 15 | import pytest |
17 | 16 | from mne.datasets import testing |
18 | 17 | from mne.io import anonymize_info |
@@ -221,50 +220,36 @@ def test_path_benchmark(tmp_path_factory): |
221 | 220 |
|
222 | 221 | # apply nosub on find_matching_matchs with root level bids directory should |
223 | 222 | # yield a performance boost of order of length from bids_subdirectories. |
224 | | - timed_all, timed_ignored_nosub = ( |
225 | | - timeit.timeit( |
226 | | - "mne_bids.find_matching_paths(tmp_bids_root)", |
227 | | - setup="import mne_bids\ntmp_bids_root=r'" + str(tmp_bids_root) + "'", |
228 | | - number=1, |
229 | | - ), |
230 | | - timeit.timeit( |
231 | | - "mne_bids.find_matching_paths(tmp_bids_root, ignore_nosub=True)", |
232 | | - setup="import mne_bids\ntmp_bids_root=r'" + str(tmp_bids_root) + "'", |
233 | | - number=10, |
234 | | - ) |
235 | | - / 10, |
| 223 | + setup = "import mne_bids\ntmp_bids_root=r'" + str(tmp_bids_root) + "'" |
| 224 | + timed_all = timeit.timeit( |
| 225 | + "mne_bids.find_matching_paths(tmp_bids_root)", setup=setup, number=1 |
236 | 226 | ) |
237 | | - |
238 | | - assert ( |
239 | | - timed_all / (10 * np.maximum(1, np.floor(len(bids_subdirectories) / 10))) |
240 | | - # while this should be of same order, lets give it some space by a factor of 2 |
241 | | - > 0.5 * timed_ignored_nosub |
| 227 | + timed_ignored_nosub = timeit.timeit( |
| 228 | + "mne_bids.find_matching_paths(tmp_bids_root, ignore_nosub=True)", |
| 229 | + setup=setup, |
| 230 | + number=1, |
242 | 231 | ) |
243 | 232 |
|
| 233 | + # while this should be of same order, lets give it some space by a factor of 2 |
| 234 | + target = 2 * timed_all / len(bids_subdirectories) |
| 235 | + assert timed_ignored_nosub < target |
| 236 | + |
244 | 237 | # apply include_match on get_entity_vals with root level bids directory should |
245 | 238 | # yield a performance boost of order of length from bids_subdirectories. |
246 | | - timed_entity, timed_entity_match = ( |
247 | | - timeit.timeit( |
248 | | - "mne_bids.get_entity_vals(tmp_bids_root, 'session')", |
249 | | - setup="import mne_bids\ntmp_bids_root=r'" + str(tmp_bids_root) + "'", |
250 | | - number=1, |
251 | | - ), |
252 | | - timeit.timeit( |
253 | | - "mne_bids.get_entity_vals(tmp_bids_root, 'session', include_match='sub-*/')", # noqa: E501 |
254 | | - setup="import mne_bids\ntmp_bids_root=r'" + str(tmp_bids_root) + "'", |
255 | | - number=10, |
256 | | - ) |
257 | | - / 10, |
| 239 | + timed_entity = timeit.timeit( |
| 240 | + "mne_bids.get_entity_vals(tmp_bids_root, 'session')", |
| 241 | + setup=setup, |
| 242 | + number=1, |
258 | 243 | ) |
259 | | - |
260 | | - assert ( |
261 | | - timed_entity / (10 * np.maximum(1, np.floor(len(bids_subdirectories) / 10))) |
262 | | - # while this should be of same order, lets give it some space by a factor of 2 |
263 | | - > 0.5 * timed_entity_match |
| 244 | + timed_entity_match = timeit.timeit( |
| 245 | + "mne_bids.get_entity_vals(tmp_bids_root, 'session', include_match='sub-*/')", # noqa: E501 |
| 246 | + setup=setup, |
| 247 | + number=1, |
264 | 248 | ) |
265 | 249 |
|
266 | | - # Clean up |
267 | | - shutil.rmtree(tmp_bids_root) |
| 250 | + # while this should be of same order, lets give it some space by a factor of 2 |
| 251 | + target = 2 * timed_entity / len(bids_subdirectories) |
| 252 | + assert timed_entity_match < target |
268 | 253 |
|
269 | 254 |
|
270 | 255 | def test_search_folder_for_text(capsys): |
|
0 commit comments