Skip to content

Instantly share code, notes, and snippets.

@AStupidBear
Last active March 30, 2020 04:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AStupidBear/df53fcec7287eebec6c2da131711adf4 to your computer and use it in GitHub Desktop.
Save AStupidBear/df53fcec7287eebec6c2da131711adf4 to your computer and use it in GitHub Desktop.
Compile Plots.jl to shorten first-to-plot time
#!/usr/bin/env julia
using Pkg
pkg"add PackageCompiler Plots StatsPlots PyPlot"
using PackageCompiler
snoop = tempname()
open(snoop, "w") do fid
println(fid, "using Plots")
println(fid, "p=plot(rand(5), rand(5))")
println(fid, "display(p)")
end
if get(ENV, "FORCE", "0") == "1"
create_sysimage(:Plots, replace_default = true, precompile_execution_file = snoop, cpu_target = "x86_64")
else
cd(mkpath(expanduser("~/.cache/sysimg")))
create_sysimage(:Plots, sysimage_path = "sys_plots.so", precompile_execution_file = snoop, cpu_target = "x86_64")
cd(Sys.BINDIR)
str = """
#!/bin/bash
julia -J ~/.cache/sysimg/sys_plots.so \"\$@\"
"""
write("pjulia", str)
chmod("pjulia", 0o775)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment