"examples/vscode:/vscode.git/clone" did not exist on "8435b993b3311c2725893cc0a010da757e2540a1"
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): ...@@ -36,9 +36,9 @@ def tmpdir_manager(base_dir: Optional[str] = None):
@contextlib.contextmanager @contextlib.contextmanager
def timing(msg: str): def timing(msg: str):
logging.info("Started %s", msg) logging.info("Started %s", msg)
tic = time.time() tic = time.perf_counter()
yield yield
toc = time.time() toc = time.perf_counter()
logging.info("Finished %s in %.3f seconds", msg, toc - tic) logging.info("Finished %s in %.3f seconds", msg, toc - tic)
......
...@@ -435,7 +435,7 @@ def _run_one_iteration( ...@@ -435,7 +435,7 @@ def _run_one_iteration(
tolerance = tolerance * ENERGY tolerance = tolerance * ENERGY
stiffness = stiffness * ENERGY / (LENGTH ** 2) stiffness = stiffness * ENERGY / (LENGTH ** 2)
start = time.time() start = time.perf_counter()
minimized = False minimized = False
attempts = 0 attempts = 0
while not minimized and attempts < max_attempts: while not minimized and attempts < max_attempts:
...@@ -457,7 +457,7 @@ def _run_one_iteration( ...@@ -457,7 +457,7 @@ def _run_one_iteration(
logging.info(e) logging.info(e)
if not minimized: if not minimized:
raise ValueError(f"Minimization failed after {max_attempts} attempts.") 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 ret["min_attempts"] = attempts
return ret return ret
......
...@@ -138,9 +138,9 @@ def main(args): ...@@ -138,9 +138,9 @@ def main(args):
for k,v in batch.items() for k,v in batch.items()
} }
t = time.time() t = time.perf_counter()
out = model(batch) 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 # Toss out the recycling dimensions --- we don't need them anymore
batch = tensor_tree_map(lambda x: np.array(x[..., -1].cpu()), batch) batch = tensor_tree_map(lambda x: np.array(x[..., -1].cpu()), batch)
...@@ -164,9 +164,9 @@ def main(args): ...@@ -164,9 +164,9 @@ def main(args):
) )
# Relax the prediction. # Relax the prediction.
t = time.time() t = time.perf_counter()
relaxed_pdb_str, _, _ = amber_relaxer.process(prot=unrelaxed_protein) 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. # Save the relaxed PDB.
relaxed_output_path = os.path.join( 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