# HG changeset patch # User Rik # Date 1713494603 25200 # Node ID 761b404e9569423b235218bd014e074d6fab77db # Parent 83352d86f20d5de5116dbcf7ed6c5bd141491b32 profile.m: Stop profiler when "clear" option given. * profile.m: Document that option "clear" will also stop profiler. In "clear" case statement, call "__profiler_enable__ (false)" if profiler is running. Simplify "status" case statement by using ifelse function. Remove obsolete BIST test. diff -r 83352d86f20d -r 761b404e9569 scripts/profiler/profile.m --- a/scripts/profiler/profile.m Thu Apr 18 21:03:51 2024 +0200 +++ b/scripts/profiler/profile.m Thu Apr 18 19:43:23 2024 -0700 @@ -41,7 +41,7 @@ ## with @code{T = profile ("info")}. ## ## @item profile clear -## Clear all collected profiler data. +## Clear all collected profiler data and stop profiling. ## ## @item profile resume ## Restart profiling without clearing the old data. All newly collected @@ -84,18 +84,16 @@ __profiler_enable__ (false); case "clear" + if (__profiler_enable__ ()) + __profiler_enable__ (false); + endif __profiler_reset__ (); case "resume" __profiler_enable__ (true); case "status" - enabled = __profiler_enable__ (); - if (enabled) - enabled = "on"; - else - enabled = "off"; - endif + enabled = ifelse (__profiler_enable__ (), 'on', 'off'); retval = struct ("ProfilerStatus", enabled); case "info" @@ -156,5 +154,4 @@ ## Test input validation %!error profile () -%!error profile ("on", 2) %!error profile ("INVALID_OPTION")