Skip to content

Commit e2b1330

Browse files
committed
performance_log can be bool
1 parent 0dad230 commit e2b1330

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

activitysim/core/configuration/base.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,27 @@ def pandas_option_context(self):
234234
else:
235235
yield
236236

237-
performance_log: Path | None = None
237+
performance_log: Path | bool | None = None
238238
"""Log runtime performance to this file.
239239
240240
The runtime performance log shows the time taken to evaluate each
241241
expression in the specification files. It is useful for debugging
242242
performance issues with complex expressions.
243243
244-
If set to None (the default), no performance logging will be done."""
244+
Giving a filename here will override the global performance logging
245+
setting, and will log performance to the specified file, unless the
246+
global performance logging setting is set to `False`, in which case
247+
no performance logging will be done for any component.
248+
249+
If set to `True`, performance logging will be activated, and the filename
250+
will be chosen based on the trace label for this component.
251+
252+
If this path is set to None (the default), performance logging will be
253+
activated based on the global performance logging setting, and the filename
254+
will be chosen based on the trace label for this component. This is strongly
255+
recommended for most use cases, unless the trace label causes the filename
256+
to be too long or otherwise unsuitable for the filesystem.
257+
"""
245258

246259
def subcomponent_settings(self, subcomponent: str) -> ComputeSettings:
247260
"""Get the sharrow settings for a particular subcomponent."""

activitysim/core/interaction_simulate.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,13 @@ def to_series(x):
270270
and compute_settings.performance_log is None
271271
):
272272
perf_log_file = Path(trace_label + ".log")
273-
elif state.settings.expression_profile is False:
273+
elif (
274+
state.settings.expression_profile is False
275+
or compute_settings.performance_log is False
276+
):
274277
perf_log_file = None
278+
elif compute_settings.performance_log is True:
279+
perf_log_file = Path(trace_label + ".log")
275280
else:
276281
perf_log_file = compute_settings.performance_log
277282
performance_timer = timing.EvalTiming(perf_log_file)

activitysim/core/simulate.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,13 @@ def eval_utilities(
634634
and compute_settings.performance_log is None
635635
):
636636
perf_log_file = Path(trace_label + ".log")
637-
elif state.settings.expression_profile is False:
637+
elif (
638+
state.settings.expression_profile is False
639+
or compute_settings.performance_log is False
640+
):
638641
perf_log_file = None
642+
elif compute_settings.performance_log is True:
643+
perf_log_file = Path(trace_label + ".log")
639644
else:
640645
perf_log_file = compute_settings.performance_log
641646
performance_timer = timing.EvalTiming(perf_log_file)

0 commit comments

Comments
 (0)