-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dev script to profile caching performance
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}") | ||
|
||
|
||
print_timing(agasc_dec, cache=False) | ||
print_timing(agasc_dec, cache=True) | ||
print_timing(agasc_healpix, cache=False) | ||
print_timing(agasc_healpix, cache=True) |