Skip to content

Commit

Permalink
Add dev script to profile caching performance
Browse files Browse the repository at this point in the history
  • Loading branch information
taldcroft committed Oct 3, 2023
1 parent 476e183 commit c41fe20
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions dev/profile_cache.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Profile performance of get_agasc_cone with and without cache"""
import time
from pathlib import Path

import numpy as np

from agasc import get_agasc_cone, get_agasc_filename

agasc_healpix = get_agasc_filename("proseco_agasc_*", version="1p8", allow_rc=True)
agasc_dec = get_agasc_filename("proseco_agasc_*", version="1p7")

ras = np.random.uniform(0, 360, 100)
decs = np.random.uniform(-90, 90, 100)


def print_timing(filename, cache):
t0 = time.time()
for ra, dec in zip(ras, decs):
get_agasc_cone(
ra,
dec,
radius=1.5,
agasc_file=filename,
date="2019:001",
cache=cache,
)
print(f"filename={Path(filename).name} {cache=} {time.time() - t0:.2f}")


print_timing(agasc_dec, cache=False)
print_timing(agasc_dec, cache=True)
print_timing(agasc_healpix, cache=False)
print_timing(agasc_healpix, cache=True)

0 comments on commit c41fe20

Please sign in to comment.