Skip to content

Commit

Permalink
move time_imports to Base but keep as published from InteractiveUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Oct 21, 2024
1 parent 8bdacc3 commit 838cf4f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
13 changes: 13 additions & 0 deletions base/timing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 4 additions & 11 deletions stdlib/InteractiveUtils/src/macros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))

"""
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 838cf4f

Please sign in to comment.