Skip to content

Instantly share code, notes, and snippets.

@samusz
Forked from KristofferC/LatencyCheck.jl
Created June 26, 2019 21:47
Show Gist options
  • Save samusz/f8d376fb3e065885ffdedd732bb8afd6 to your computer and use it in GitHub Desktop.
Save samusz/f8d376fb3e065885ffdedd732bb8afd6 to your computer and use it in GitHub Desktop.
using Statistics
using Printf
import Pkg
const JULIA_CMD = Base.julia_cmd()
run_cmd(cmd) = run(`$JULIA_CMD --startup=no --history-file=no -e $cmd`)
const N_STARTUP_RUNS = 5
function run_latency_check()
mktempdir() do depot_path
withenv("JULIA_DEPOT_PATH" => depot_path, "JULIA_LOAD_PATH" => nothing) do
print("Checking time to start Julia... ")
startup_times = [@elapsed run_cmd(`nothing`) for i in 1:N_STARTUP_RUNS]
m_startup, std_startup = mean(startup_times), std(startup_times)
@printf("%.3fs (%.3fs)\n", m_startup ,std_startup)
# Seems like we need TimeZones master on 1.1
run_cmd("""import Pkg; Pkg.add(Pkg.PackageSpec(name="TimeZones", rev="master")); Pkg.add(["DataFrames", "Gadfly"])""")
print("Checking time to precompile DataFrames... ")
precompile_dataframes = @elapsed run_cmd("import DataFrames")
@printf("%.3fs\n", precompile_dataframes)
print("Checking time to load DataFrames... ")
load_dataframes = @elapsed run_cmd("import DataFrames")
@printf("%.3fs\n", load_dataframes)
print("Checking time to precompile Gadfly... ")
precompile_gadfly = @elapsed run_cmd("import Gadfly")
@printf("%.3fs\n", precompile_gadfly)
print("Checking time to load Gadfly... ")
load_gadfly = @elapsed run_cmd("import Gadfly")
@printf("%.3fs\n", load_gadfly)
print("Checking time to plot with Gadfly... ")
plot_gadfly = (@elapsed run_cmd("import Gadfly; p = Gadfly.plot(y=[1,2,3]); display(p)")) - load_gadfly
@printf("%.3fs\n", plot_gadfly)
println("| Startup [s] | Prec DataFrames [s] | Load DataFrames [s] | Prec Gadfly [s] | Load Gadfly [s] | Plot Gadfly [s] |")
println("|-------------|---------------------|---------------------|-----------------|-----------------|-----------------|")
@printf("| %.3f | %.3f | %.3f | %.3f | %.3f | %.3f |", m_startup, precompile_dataframes,
load_dataframes, precompile_gadfly, load_gadfly, plot_gadfly)
end
end
return
end
run_latency_check()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment