Skip to content

Commit 1390cc3

Browse files
Use time.perf_counter for aesara.function timing results
1 parent 471657a commit 1390cc3

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

aesara/compile/function/types.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ def restore_defaults():
824824
self[i] = value
825825

826826
profile = self.profile
827-
t0 = time.time()
827+
t0 = time.perf_counter()
828828

829829
output_subset = kwargs.pop("output_subset", None)
830830
if output_subset is not None and self.output_keys is not None:
@@ -965,7 +965,7 @@ def restore_defaults():
965965
)
966966

967967
# Do the actual work
968-
t0_fn = time.time()
968+
t0_fn = time.perf_counter()
969969
try:
970970
outputs = (
971971
self.vm()
@@ -991,7 +991,7 @@ def restore_defaults():
991991
# old-style linkers raise their own exceptions
992992
raise
993993

994-
dt_fn = time.time() - t0_fn
994+
dt_fn = time.perf_counter() - t0_fn
995995
self.maker.mode.fn_time += dt_fn
996996
if profile:
997997
profile.vm_call_time += dt_fn
@@ -1039,7 +1039,7 @@ def restore_defaults():
10391039
# grep for 'PROFILE_CODE'
10401040
#
10411041

1042-
dt_call = time.time() - t0
1042+
dt_call = time.perf_counter() - t0
10431043
aesara.compile.profiling.total_fct_exec_time += dt_call
10441044
self.maker.mode.call_time += dt_call
10451045
if profile:
@@ -1395,7 +1395,7 @@ def prepare_fgraph(
13951395
):
13961396

13971397
try:
1398-
start_rewriter = time.time()
1398+
start_rewriter = time.perf_counter()
13991399

14001400
rewriter_profile = None
14011401
rewrite_time = None
@@ -1406,7 +1406,7 @@ def prepare_fgraph(
14061406
):
14071407
rewriter_profile = rewriter(fgraph)
14081408

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

@@ -1416,7 +1416,7 @@ def prepare_fgraph(
14161416

14171417
# If the rewriter got interrupted
14181418
if rewrite_time is None:
1419-
end_rewriter = time.time()
1419+
end_rewriter = time.perf_counter()
14201420
rewrite_time = end_rewriter - start_rewriter
14211421

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

16471647
# Get a function instance
1648-
start_linker = time.time()
1648+
start_linker = time.perf_counter()
16491649
start_import_time = aesara.link.c.cmodule.import_time
16501650

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

1656-
end_linker = time.time()
1656+
end_linker = time.perf_counter()
16571657

16581658
linker_time = end_linker - start_linker
16591659
aesara.compile.profiling.total_time_linker += linker_time
@@ -1725,7 +1725,7 @@ def orig_function(
17251725
17261726
"""
17271727

1728-
t1 = time.time()
1728+
t1 = time.perf_counter()
17291729
mode = aesara.compile.mode.get_mode(mode)
17301730

17311731
inputs = list(map(convert_function_input, inputs))
@@ -1758,7 +1758,7 @@ def orig_function(
17581758
with config.change_flags(compute_test_value="off"):
17591759
fn = m.create(defaults)
17601760
finally:
1761-
t2 = time.time()
1761+
t2 = time.perf_counter()
17621762
if fn and profile:
17631763
profile.compile_time += t2 - t1
17641764
# TODO: append

0 commit comments

Comments
 (0)