@@ -1474,15 +1474,20 @@ def __init__(
1474
1474
if getattr (mode , "profile" , None ):
1475
1475
raise TypeError ("profile passed via 'mode'. This isn't supported anymore" )
1476
1476
self .profile = profile
1477
- if profile :
1477
+ if profile and config . cxx :
1478
1478
# This is very important:
1479
1479
# 1) We preload the cache here to not have its timing
1480
1480
# included with the rewrites.
1481
1481
# 2) Do not refresh the cache here by default. It cause
1482
1482
# too much execution time during testing as we compile
1483
1483
# much more functions then the number of compile c
1484
1484
# module.
1485
+ start_get_cache = time .perf_counter ()
1485
1486
pytensor .link .c .basic .get_module_cache ().refresh ()
1487
+ get_cache_time = time .perf_counter () - start_get_cache
1488
+ self .profile .linker_time += get_cache_time
1489
+ self .profile .preload_cache_time += get_cache_time
1490
+
1486
1491
# Handle the case where inputs and/or outputs is a single
1487
1492
# Variable (not in a list)
1488
1493
unpack_single = False
@@ -1722,7 +1727,8 @@ def orig_function(
1722
1727
1723
1728
"""
1724
1729
1725
- t1 = time .perf_counter ()
1730
+ if profile :
1731
+ t1 = time .perf_counter ()
1726
1732
mode = pytensor .compile .mode .get_mode (mode )
1727
1733
1728
1734
inputs = list (map (convert_function_input , inputs ))
@@ -1755,8 +1761,8 @@ def orig_function(
1755
1761
with config .change_flags (compute_test_value = "off" ):
1756
1762
fn = m .create (defaults )
1757
1763
finally :
1758
- t2 = time . perf_counter ()
1759
- if fn and profile :
1764
+ if profile and fn :
1765
+ t2 = time . perf_counter ()
1760
1766
profile .compile_time += t2 - t1
1761
1767
# TODO: append
1762
1768
profile .nb_nodes = len (fn .maker .fgraph .apply_nodes )
0 commit comments