Skip to content

Commit 9ab4ece

Browse files
committed
Add timing log messages
1 parent 0e34cb4 commit 9ab4ece

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

python/lsst/ap/association/testApdb.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
import numpy as np
3232
import pandas as pd
33+
import time
3334

3435
from lsst.daf.base import DateTime
3536
import lsst.dax.apdb as daxApdb
@@ -210,6 +211,7 @@ def run(self, visit, detector,
210211
idGeneratorForced : `lsst.meas.base,IdGenerator`, optional
211212
ID generator for forced sources at existing diaObject locations.
212213
"""
214+
t_sim0 = time.time()
213215
idGen = idGenerator.make_table_id_factory()
214216
idGenFakes = idGeneratorFakes.make_table_id_factory()
215217
idGenForced = idGeneratorForced.make_table_id_factory()
@@ -252,11 +254,16 @@ def run(self, visit, detector,
252254
diaSourcesRaw = pd.concat([diaSourcesReal, diaSourcesBogus])
253255

254256
diaSources = convertTableToSdmSchema(self.schema, diaSourcesRaw, tableName="DiaSource")
257+
t_sim1 = time.time()
258+
self.log.info("Simulated source timing: %.2fs", t_sim1 - t_sim0)
255259

260+
t_load0 = time.time()
256261
diaObjects = self.loadDiaObjects(region.getBoundingCircle(), self.schema)
262+
t_load1 = time.time()
263+
self.log.info("diaObject load timing: %.2fs", t_load1 - t_load0)
257264

258265
if diaObjects.empty:
259-
self.log.info(f"diaObjects contain 0 diaSources (empty)")
266+
self.log.info("diaObjects contain 0 diaSources (empty)")
260267
else:
261268
nDiaSources = diaObjects.nDiaSources
262269
self.log.info(f"diaObjects contain {np.min(nDiaSources)} to {np.max(nDiaSources)} diaSources")
@@ -274,18 +281,21 @@ def run(self, visit, detector,
274281
nSrc = len(associatedDiaSources)
275282
dateTime = DateTime.now().toAstropy()
276283
ind = 0
284+
t_write0 = time.time()
277285
# Note that nObj must always be equal to or greater than nSrc
278286
for start in range(0, nObj, self.config.maximum_table_length):
279287
end = min(start + self.config.maximum_table_length, nObj)
280288
diaObjectsChunk = mergedDiaObjects.iloc[start:end]
281-
self.log.info(f"Writing diaObject chunk {ind} of length {len(diaObjectsChunk)} to the APDB")
289+
nObjChunk = len(diaObjectsChunk)
290+
self.log.info(f"Writing diaObject chunk {ind} of length {nObjChunk} (of {nObj}) to the APDB")
282291
srcEnd = min(start + self.config.maximum_table_length, nSrc)
283292
if srcEnd <= start:
284293
finalDiaSources = None
285294
else:
286295
diaSourcesChunk = associatedDiaSources.iloc[start:srcEnd]
287296
finalDiaSources = convertTableToSdmSchema(self.schema, diaSourcesChunk, tableName="DiaSource")
288-
self.log.info(f"Writing diaSource chunk {ind} of length {len(diaSourcesChunk)} to the APDB")
297+
nSrcChunk = len(diaSourcesChunk)
298+
self.log.info(f"Writing diaSource chunk {ind} of length {nSrcChunk} (of {nSrc}) to the APDB")
289299
diaForcedSources = self.runForcedMeasurement(diaObjectsChunk, idGenForced, visit, detector)
290300

291301
finalDiaObjects = convertTableToSdmSchema(self.schema, diaObjectsChunk, tableName="DiaObject")
@@ -295,6 +305,8 @@ def run(self, visit, detector,
295305
f" {len(finalDiaForcedSources)} to the APDB")
296306
self.writeToApdb(finalDiaObjects, finalDiaSources, finalDiaForcedSources, dateTime)
297307
ind += 1
308+
t_write1 = time.time()
309+
self.log.info("APDB write timing: %.2fs", t_write1 - t_write0)
298310
marker = pexConfig.Config()
299311
return pipeBase.Struct(apdbTestMarker=marker)
300312

0 commit comments

Comments
 (0)