From 7a1fbb713e31015b595cd76d571a9b7d5cffa5de Mon Sep 17 00:00:00 2001 From: joncrall Date: Wed, 27 Mar 2024 15:06:59 -0400 Subject: [PATCH] Respect stripzeros in summary report --- CHANGELOG.rst | 12 ++++++++---- line_profiler/line_profiler.py | 5 +++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c99bc496..e6b9564e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,18 +1,22 @@ Changes ======= +4.1.3 +~~~~~ +* FIX: duration summary now respects the stripzeros argument. + 4.1.2 -~~~~ +~~~~~ * ENH: Add support for Python 3.12 #246 * ENH: Add osx universal2 and arm64 wheels #251 * ENH: Fix issue with integer overflow on 32 bit systems #249 4.1.1 -~~~~ +~~~~~ * FIX: ``get_stats`` is no longer slowed down when profiling many code sections #236 4.1.0 -~~~~ +~~~~~ * FIX: skipzeros now checks for zero hits instead of zero time * FIX: Fixed errors in Python 3.11 with duplicate functions. * FIX: ``show_text`` now increases column sizes or switches to scientific notation to maintain alignment @@ -24,7 +28,7 @@ Changes * ENH: Added readthedocs integration: https://kernprof.readthedocs.io/en/latest/index.html 4.0.3 -~~~~ +~~~~~ * FIX: Stop requiring bleeding-edge Cython unless necesasry (for Python 3.12). #206 4.0.2 diff --git a/line_profiler/line_profiler.py b/line_profiler/line_profiler.py index 4dd0bb08..d1d25cf7 100755 --- a/line_profiler/line_profiler.py +++ b/line_profiler/line_profiler.py @@ -467,8 +467,9 @@ def show_text(stats, unit, output_unit=None, stream=None, stripzeros=False, # Summarize the total time for each function for (fn, lineno, name), timings in stats_order: total_time = sum(t[2] for t in timings) * unit - line = '%6.2f seconds - %s:%s - %s\n' % (total_time, fn, lineno, name) - stream.write(line) + if not stripzeros or total_time: + line = '%6.2f seconds - %s:%s - %s\n' % (total_time, fn, lineno, name) + stream.write(line) def load_stats(filename):