Skip to content

Use time.perf_counter for aesara.function timing results #1262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions aesara/compile/function/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ def restore_defaults():
self[i] = value

profile = self.profile
t0 = time.time()
t0 = time.perf_counter()

output_subset = kwargs.pop("output_subset", None)
if output_subset is not None and self.output_keys is not None:
Expand Down Expand Up @@ -965,7 +965,7 @@ def restore_defaults():
)

# Do the actual work
t0_fn = time.time()
t0_fn = time.perf_counter()
try:
outputs = (
self.vm()
Expand All @@ -991,7 +991,7 @@ def restore_defaults():
# old-style linkers raise their own exceptions
raise

dt_fn = time.time() - t0_fn
dt_fn = time.perf_counter() - t0_fn
self.maker.mode.fn_time += dt_fn
if profile:
profile.vm_call_time += dt_fn
Expand Down Expand Up @@ -1039,7 +1039,7 @@ def restore_defaults():
# grep for 'PROFILE_CODE'
#

dt_call = time.time() - t0
dt_call = time.perf_counter() - t0
aesara.compile.profiling.total_fct_exec_time += dt_call
self.maker.mode.call_time += dt_call
if profile:
Expand Down Expand Up @@ -1395,7 +1395,7 @@ def prepare_fgraph(
):

try:
start_rewriter = time.time()
start_rewriter = time.perf_counter()

rewriter_profile = None
rewrite_time = None
Expand All @@ -1406,7 +1406,7 @@ def prepare_fgraph(
):
rewriter_profile = rewriter(fgraph)

end_rewriter = time.time()
end_rewriter = time.perf_counter()
rewrite_time = end_rewriter - start_rewriter
_logger.debug(f"Rewriting took {rewrite_time:f} seconds")

Expand All @@ -1416,7 +1416,7 @@ def prepare_fgraph(

# If the rewriter got interrupted
if rewrite_time is None:
end_rewriter = time.time()
end_rewriter = time.perf_counter()
rewrite_time = end_rewriter - start_rewriter

aesara.compile.profiling.total_graph_rewrite_time += rewrite_time
Expand Down Expand Up @@ -1645,15 +1645,15 @@ def create(self, input_storage=None, trustme=False, storage_map=None):
defaults.append((required, refeed, storage))

# Get a function instance
start_linker = time.time()
start_linker = time.perf_counter()
start_import_time = aesara.link.c.cmodule.import_time

with config.change_flags(traceback__limit=config.traceback__compile_limit):
_fn, _i, _o = self.linker.make_thunk(
input_storage=input_storage_lists, storage_map=storage_map
)

end_linker = time.time()
end_linker = time.perf_counter()

linker_time = end_linker - start_linker
aesara.compile.profiling.total_time_linker += linker_time
Expand Down Expand Up @@ -1725,7 +1725,7 @@ def orig_function(

"""

t1 = time.time()
t1 = time.perf_counter()
mode = aesara.compile.mode.get_mode(mode)

inputs = list(map(convert_function_input, inputs))
Expand Down Expand Up @@ -1758,7 +1758,7 @@ def orig_function(
with config.change_flags(compute_test_value="off"):
fn = m.create(defaults)
finally:
t2 = time.time()
t2 = time.perf_counter()
if fn and profile:
profile.compile_time += t2 - t1
# TODO: append
Expand Down