I was wondering why activating the environment that is already active takes a fair bit of time. See example.
Wouldn’t it make sense to check if the environment is already active and then ‘do nothing’?
Or does the activate command actually have an effect (e.g. if I added a package between two activate calls?)
Here is how I tend to run into this:
- I have some sort of script which starts with Pkg.activate.
- I amend the script in several places
- to evaluate the end result, I run 'include(“my_script.jl”)
I guess my workflow may be somewhat sub-optimal (maybe because in the earlier days VS Code did not support ALT+Enter, but only CTRL+Enter which triggers much more printing in the console…), but I wanted to ask nevertheless.
Notably, the execution times for activate
may be higher if I work on a network folder (or over some sort of tunnel).
julia> using Pkg
julia> function t()
for i=1:10
@time Pkg.activate("C:\\temp\\")
end
return nothing
end
t (generic function with 1 method)
julia> t()
Activating environment at `C:\temp\Project.toml`
0.066880 seconds (12.95 k allocations: 1.158 MiB)
Activating environment at `C:\temp\Project.toml`
0.048701 seconds (12.95 k allocations: 1.158 MiB)
Activating environment at `C:\temp\Project.toml`
0.017095 seconds (12.95 k allocations: 1.159 MiB)
Activating environment at `C:\temp\Project.toml`
0.038328 seconds (12.95 k allocations: 1.158 MiB)
Activating environment at `C:\temp\Project.toml`
0.045911 seconds (12.95 k allocations: 1.158 MiB)
Activating environment at `C:\temp\Project.toml`
0.041339 seconds (12.95 k allocations: 1.158 MiB)
Activating environment at `C:\temp\Project.toml`
0.053009 seconds (12.95 k allocations: 1.158 MiB)
Activating environment at `C:\temp\Project.toml`
0.041260 seconds (12.95 k allocations: 1.158 MiB)
Activating environment at `C:\temp\Project.toml`
0.039393 seconds (12.95 k allocations: 1.158 MiB)
Activating environment at `C:\temp\Project.toml`
0.037982 seconds (12.95 k allocations: 1.159 MiB)
(temp) pkg> st
Status `C:\temp\Project.toml`
[336ed68f] CSV v0.6.2
[a93c6f00] DataFrames v0.21.2
[c8e1da08] IterTools v1.3.0
[0f8b85d8] JSON3 v1.0.3
[b9914132] JSONTables v1.0.0
[fdbf4ff8] XLSX v0.7.2
[228000da] XMLDict v0.4.1