Commit 5a928b47 authored by Gustaf Ahdritz's avatar Gustaf Ahdritz
Browse files

Replace time.time() with time.perf_counter()

parent 0567d99c
......@@ -36,9 +36,9 @@ def tmpdir_manager(base_dir: Optional[str] = None):
@contextlib.contextmanager
def timing(msg: str):
logging.info("Started %s", msg)
tic = time.time()
tic = time.perf_counter()
yield
toc = time.time()
toc = time.perf_counter()
logging.info("Finished %s in %.3f seconds", msg, toc - tic)
......
......@@ -435,7 +435,7 @@ def _run_one_iteration(
tolerance = tolerance * ENERGY
stiffness = stiffness * ENERGY / (LENGTH ** 2)
start = time.time()
start = time.perf_counter()
minimized = False
attempts = 0
while not minimized and attempts < max_attempts:
......@@ -457,7 +457,7 @@ def _run_one_iteration(
logging.info(e)
if not minimized:
raise ValueError(f"Minimization failed after {max_attempts} attempts.")
ret["opt_time"] = time.time() - start
ret["opt_time"] = time.perf_counter() - start
ret["min_attempts"] = attempts
return ret
......
......@@ -138,9 +138,9 @@ def main(args):
for k,v in batch.items()
}
t = time.time()
t = time.perf_counter()
out = model(batch)
logging.info(f"Inference time: {time.time() - t}")
logging.info(f"Inference time: {time.perf_counter() - t}")
# Toss out the recycling dimensions --- we don't need them anymore
batch = tensor_tree_map(lambda x: np.array(x[..., -1].cpu()), batch)
......@@ -164,9 +164,9 @@ def main(args):
)
# Relax the prediction.
t = time.time()
t = time.perf_counter()
relaxed_pdb_str, _, _ = amber_relaxer.process(prot=unrelaxed_protein)
logging.info(f"Relaxation time: {time.time() - t}")
logging.info(f"Relaxation time: {time.perf_counter() - t}")
# Save the relaxed PDB.
relaxed_output_path = os.path.join(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment