Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow time_imports to return julia data that can be sorted and examined more easily #47630

Open
anandijain opened this issue Nov 18, 2022 · 2 comments
Labels
feature Indicates new feature / enhancement requests tooling

Comments

@anandijain
Copy link
Contributor

@time_imports is really great, but I was a bit surprised that you can't do things like sum the list of times to get the total time, ie #46850, nor sort them to see the longest packages to import.

I briefly looked at the code for @time_imports but it got to ccalls and didn't see an easy way to expose the data generated.

doing this would allow us to track using times for big ecosystem packages across julia versions and package versions.
is there a way to do this that I don't know about?

my temporary solution is to run julia --project --startup=no -E 'using InteractiveUtils; @time_imports using DifferentialEquations' and then just parse it sloppily

@anandijain
Copy link
Contributor Author

# julia --project --startup=no -E 'using InteractiveUtils; @time_imports using DifferentialEquations' > timings.txt
using CSV, DataFrames
fn = "timings.txt"
ls = strip.(readlines(fn))
cols = split.(ls, "  ")
last.(cols)
df = DataFrame(time=Float64[], unit=String[], pkg=String[], comp=Union{Missing, String}[])
for (i, col) in enumerate(cols)
    time = first(col)
    time, unit = split(time, " ")
    time = parse(Float64, time)
    pkg_and_comp = last(col)
    foo = split(pkg_and_comp, " ";limit=2)
    length(foo) == 1 ? (pkg, comp) = (foo[1], missing) : (pkg, comp) = foo
    row = vec([time unit pkg comp])
    push!(df, row)
end

sort!(df, :time; rev=true)
sum(df.time)

This is somewhat useful

@brenhinkeller brenhinkeller added feature Indicates new feature / enhancement requests tooling labels Nov 21, 2022
@jmanthony3
Copy link

# julia --project --startup=no -E 'using InteractiveUtils; @time_imports using DifferentialEquations' > timings.txt
using CSV, DataFrames
fn = "timings.txt"
ls = strip.(readlines(fn))
cols = split.(ls, "  ")
last.(cols)
df = DataFrame(time=Float64[], unit=String[], pkg=String[], comp=Union{Missing, String}[])
for (i, col) in enumerate(cols)
    time = first(col)
    time, unit = split(time, " ")
    time = parse(Float64, time)
    pkg_and_comp = last(col)
    foo = split(pkg_and_comp, " ";limit=2)
    length(foo) == 1 ? (pkg, comp) = (foo[1], missing) : (pkg, comp) = foo
    row = vec([time unit pkg comp])
    push!(df, row)
end

sort!(df, :time; rev=true)
sum(df.time)

This is somewhat useful

Thanks for this little scriplet! It has been rather handy. In case it were relevant, I added some capability with Unitful.jl to get the returned load times into the same set of units (preferrably seconds).

function timings_results(cols)
    load_time, df = 0. * u"s", DataFrame(time=Float64[], unit=String[], pkg=String[], comp=Union{Missing, String}[])
    for (i, col)  enumerate(cols)
        time, unit      = split(first(col), " ")
        time            = parse(Float64, time)
        pkg_and_comp    = last(col)
        foo = split(pkg_and_comp, " "; limit=2)
        length(foo) == 1 ? (pkg, comp) = (foo[1], missing) : (pkg, comp) = foo
        row = vec([time unit pkg comp])
        push!(df, row)
        load_time += upreferred(time*uparse(unit))
    end
    @printf("Total load time: %.3f s", uconvert(NoUnits, load_time * u"1/s"))
    return nothing
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Indicates new feature / enhancement requests tooling
Projects
None yet
Development

No branches or pull requests

3 participants