From 838cf4f7268a56ccbb9af82fdfb5eb518aec8241 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Mon, 21 Oct 2024 11:37:09 -0400 Subject: [PATCH] move time_imports to Base but keep as published from InteractiveUtils --- base/timing.jl | 13 +++++++++++++ stdlib/InteractiveUtils/src/macros.jl | 15 ++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/base/timing.jl b/base/timing.jl index 4880951f0a32d..4e678bdfa0df4 100644 --- a/base/timing.jl +++ b/base/timing.jl @@ -628,3 +628,16 @@ macro timed(ex) ) end end + +# Exported, documented, and tested in InteractiveUtils +# here so it's possible to time all imports, including InteractiveUtils and its deps +macro time_imports(ex) + quote + try + Base.Threads.atomic_add!(Base.TIMING_IMPORTS, 1) + $(esc(ex)) + finally + Base.Threads.atomic_sub!(Base.TIMING_IMPORTS, 1) + end + end +end diff --git a/stdlib/InteractiveUtils/src/macros.jl b/stdlib/InteractiveUtils/src/macros.jl index 211687df47954..1fa1fcd8bef38 100644 --- a/stdlib/InteractiveUtils/src/macros.jl +++ b/stdlib/InteractiveUtils/src/macros.jl @@ -4,6 +4,10 @@ import Base: typesof, insert!, replace_ref_begin_end!, infer_effects +# defined in Base so it's possible to time all imports, including InteractiveUtils and its deps +# via. `Base.@time_imports` +import Base: @time_imports + separate_kwargs(args...; kwargs...) = (args, values(kwargs)) """ @@ -245,17 +249,6 @@ macro code_lowered(ex0...) end end -macro time_imports(ex) - quote - try - Base.Threads.atomic_add!(Base.TIMING_IMPORTS, 1) - $(esc(ex)) - finally - Base.Threads.atomic_sub!(Base.TIMING_IMPORTS, 1) - end - end -end - macro trace_compile(ex) quote try