Skip to content

Commit 3168633

Browse files
measuere time it takes to Autosave for logger
1 parent d8577dd commit 3168633

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
@@ -204,13 +204,14 @@ def autosave_function(
204204
counter: Optional[Union[int, str]] = None,
205205
auxiliary_data: Optional[Dict[str, Any]] = None,
206206
) -> None:
207+
t0 = time.perf_counter()
207208
if counter is not None:
208-
logger.debug(f"💾 Autosaving to {str(filename)}.{counter}")
209209
unitcell.save_to_file(
210210
f"{str(filename)}.{counter}", auxiliary_data=auxiliary_data
211211
)
212+
logger.debug(f"💾 Autosaving to {str(filename)}.{counter}, took {time.perf_counter() - t0:.2f} sec")
212213
else:
213-
logger.debug(f"💾 Autosaving to {str(filename)}")
214+
logger.debug(f"💾 Autosaving to {str(filename)}, took {time.perf_counter() - t0:.2f} sec")
214215
unitcell.save_to_file(filename, auxiliary_data=auxiliary_data)
215216

216217

@@ -235,6 +236,7 @@ def autosave_function_restartable(
235236
signal_reset_descent_dir,
236237
) -> None:
237238
state_filename = os.environ.get("VARIPEPS_STATE_FILE")
239+
t0 = time.perf_counter()
238240
if state_filename is None:
239241
state_filename = f"{str(filename)}.restartable"
240242
with h5py.File(state_filename, "w", libver=("earliest", "v110")) as f:
@@ -365,6 +367,7 @@ def autosave_function_restartable(
365367
compression="gzip",
366368
compression_opts=6,
367369
)
370+
logger.debug(f"💾 Restartable autosaving to {str(state_filename)}, took {time.perf_counter() - t0:.2f} sec")
368371

369372

370373
def _autosave_wrapper(
@@ -497,6 +500,7 @@ def optimize_peps_network(
497500
final expectation value. See the type definition for other possible
498501
fields.
499502
"""
503+
logger.info("🛠️ Starting optimization ... ")
500504
rng = PEPS_Random_Number_Generator.get_generator(backend="jax")
501505

502506
def random_noise(a):

0 commit comments

Comments
 (0)