Skip to content

Commit

Permalink
Add new test of timing
Browse files Browse the repository at this point in the history
  • Loading branch information
taldcroft committed May 12, 2020
1 parent accaae9 commit d12713f
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions proseco/tests/timing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst

"""
Provide a function to check for timing regressions for any changes.
"""

import time
import sys

import numpy as np

from proseco import get_aca_catalog
from proseco.tests.test_common import mod_std_info


def time_get_aca_catalog(n_samples=100):
"""
Get n_samples catalogs for standard parameters (all at the same 2018:001) date.
"""

np.random.seed(0)

ras = np.random.uniform(0, 360, size=n_samples)
decs = np.random.uniform(-90, 90, size=n_samples)
rolls = np.random.uniform(0, 360, size=n_samples)

# Get rid of initial imports or one-time startup stuff (e.g. in AGASC)
get_aca_catalog(**mod_std_info())

t0 = time.time()
for ra, dec, roll in zip(ras, decs, rolls):
print('.', end='')
sys.stdout.flush()
get_aca_catalog(**mod_std_info(att=(ra, dec, roll)))

t1 = time.time()
print()

print(f'Got {n_samples} catalogs in {(t1 - t0) / n_samples:.3f} secs (mean)')

0 comments on commit d12713f

Please sign in to comment.