Skip to content

Commit 1906ff5

Browse files
measuere time it takes to Autosave for logger
1 parent f484860 commit 1906ff5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

varipeps/optimization/optimizer.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,13 +269,14 @@ def autosave_function(
269269
counter: Optional[Union[int, str]] = None,
270270
auxiliary_data: Optional[Dict[str, Any]] = None,
271271
) -> None:
272+
t0 = time.perf_counter()
272273
if counter is not None:
273-
logger.debug(f"💾 Autosaving to {str(filename)}.{counter}")
274274
unitcell.save_to_file(
275275
f"{str(filename)}.{counter}", auxiliary_data=auxiliary_data
276276
)
277+
logger.debug(f"💾 Autosaving to {str(filename)}.{counter}, took {time.perf_counter() - t0:.2f} sec")
277278
else:
278-
logger.debug(f"💾 Autosaving to {str(filename)}")
279+
logger.debug(f"💾 Autosaving to {str(filename)}, took {time.perf_counter() - t0:.2f} sec")
279280
unitcell.save_to_file(filename, auxiliary_data=auxiliary_data)
280281

281282

@@ -300,6 +301,7 @@ def autosave_function_restartable(
300301
signal_reset_descent_dir,
301302
) -> None:
302303
state_filename = os.environ.get("VARIPEPS_STATE_FILE")
304+
t0 = time.perf_counter()
303305
if state_filename is None:
304306
state_filename = f"{str(filename)}.restartable"
305307
with h5py.File(state_filename, "w", libver=("earliest", "v110")) as f:
@@ -430,6 +432,7 @@ def autosave_function_restartable(
430432
compression="gzip",
431433
compression_opts=6,
432434
)
435+
logger.debug(f"💾 Restartable autosaving to {str(state_filename)}, took {time.perf_counter() - t0:.2f} sec")
433436

434437

435438
def _autosave_wrapper(
@@ -562,6 +565,7 @@ def optimize_peps_network(
562565
final expectation value. See the type definition for other possible
563566
fields.
564567
"""
568+
logger.info("🛠️ Starting optimization ... ")
565569
rng = PEPS_Random_Number_Generator.get_generator(backend="jax")
566570

567571
def random_noise(a):

0 commit comments

Comments
 (0)