Skip to content

Instantly share code, notes, and snippets.

@tkf

tkf/.gitignore Secret

Last active January 4, 2022 02:09
Show Gist options
  • Save tkf/23aac6fb96ed5dd53b8e03564254b226 to your computer and use it in GitHub Desktop.
Save tkf/23aac6fb96ed5dd53b8e03564254b226 to your computer and use it in GitHub Desktop.
*.ipynb
/Manifest.toml
/build
/result
/tmp
/var
/config.mk
using SchedulersBenchmarks
SUITE = SchedulersBenchmarks.BenchFib.setup()
include config.mk
JULIA ?= julia
JULIA_CMD ?= $(JULIA) --color=yes --startup-file=no
export JULIA_LOAD_PATH = @
export JULIA_PROJECT = $(shell pwd)
RESULT_TARGETS = result/00_notebook.ipynb
.PHONY: all benchmark retry-benchmark instantiate checkout result result-*
default: benchmark
all: benchmark
$(MAKE) notebook.ipynb
benchmark: var/benchmark.done
var/benchmark.done: Manifest.toml
@mkdir -p var
$(JULIA_CMD) run.jl
touch $@
retry-benchmark:
@rm -f var/benchmark.done
@$(MAKE) benchmark
notebook.ipynb: notebook.jl var/instantiate.done
$(JULIA_CMD) run_literate.jl notebook.jl
instantiate: var/instantiate.done
var/instantiate.done: Manifest.toml
@mkdir -p var
JULIA_LOAD_PATH=@:@stdlib $(JULIA_CMD) -e 'using Pkg; Pkg.instantiate()'
touch $@
Manifest.toml: Project.toml
JULIA_LOAD_PATH=@:@stdlib $(JULIA_CMD) \
-e 'using Pkg' \
-e 'Pkg.add(url = "https://github.com/tkf/GitDataManager.jl.git")' \
-e 'Pkg.resolve()'
repl:
JULIA_LOAD_PATH=: $(JULIA)
config.mk:
touch $@
# ln -s default-config.mk $@
clean:
-$(MAKE) result-clean
rm -f notebook.ipynb
checkout:
git clone git@gist.github.com:2e522274e00d17c69da9d82bc8138348 result
result: $(RESULT_TARGETS)
result/00_notebook.ipynb: notebook.ipynb
@mkdir -p result
cp $< $@
result-commit result-upload result-empty: result-%:
time $(JULIA_CMD) --compile=min -e 'using GitDataManager; GitDataManager.$*("result")'
result-clean: result-empty
rm -f notebook.ipynb
result-publish: result-clean
$(MAKE) result
$(MAKE) result-upload
# # Example notebook
import BenchmarkConfigSweeps
import DisplayAs
using DataFrames
using FileIO: save
using InteractiveUtils
using VegaLite
sweepresult = BenchmarkConfigSweeps.load(joinpath(@__DIR__, "build"))
resultdir = joinpath(@__DIR__, "result")
mkpath(resultdir)
function save_vlplot(name::AbstractString, plt)
save(joinpath(resultdir, name * ".png"), plt)
save(joinpath(resultdir, name * ".svg"), plt)
save(joinpath(resultdir, name * ".vegalite"), plt)
return DisplayAs.PNG(plt)
end
nothing # hide
#-
df_raw = DataFrame(sweepresult)
begin
df = select(df_raw, Not(:trial))
df[:, :time_ns] = map(t -> minimum(t).time, df_raw.trial)
idx_baseline = only(findall((df.nthreads .== 1) .& (df.scheduler .== :base)))
df[:, :speedup] = df[idx_baseline, :time_ns] ./ df.time_ns
df
end
#-
plt = @vlplot(
layer = [
{
mark = {:line, point = true},
x = :nthreads,
y = {field = :speedup, title = "Speedup w.r.t base nthreads=1"},
color = {:scheduler, type = :nominal},
},
{mark = {type = :rule}, encoding = {y = {datum = 1}}},
],
data = df,
)
save_vlplot("plt_speedup", plt)
#-
# ## Julia version information
versioninfo()
#-
Base.GIT_VERSION_INFO
#-
[deps]
BenchmarkConfigSweeps = "5dead3b6-c9e4-435a-a292-80e2716ed6d9"
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DisplayAs = "0b91fe84-8a4c-11e9-3e1d-67c38462b6d6"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
GitDataManager = "e46aa908-4c54-40d5-94de-678bb20abb10"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
Schedulers = "fce7a5f1-5486-4c58-95c0-c14b9119c17a"
SchedulersBenchmarks = "84c47252-7670-4a95-9172-43d9ab0f346b"
VegaLite = "112f6efa-9a02-5b7d-90c0-432ed331239a"
using BenchmarkConfigSweeps
BenchmarkConfigSweeps.run(
joinpath(@__DIR__, "build"),
joinpath(@__DIR__, "benchmarks.jl"),
BenchmarkConfigSweeps.nthreads.(1:min(16, cld(Sys.CPU_THREADS, 2))),
)
if abspath(PROGRAM_FILE) == @__FILE__
INPUTFILE = abspath(ARGS[1])
else
INPUTFILE = joinpath(@__DIR__, "notebook.jl")
end
using Literate
function preprocess_natural_comment(str)
output = IOBuffer()
input = IOBuffer(str)
while !eof(input)
ln = readline(input; keep = true)
# Always treat indented comments as in-code comments
m = match(r"^( +)# (.*)"s, ln)
if m !== nothing
print(output, m[1], "## ", m[2])
continue
end
print(output, ln)
end
return String(take!(output))
end
Literate.notebook(INPUTFILE, @__DIR__; preprocess = preprocess_natural_comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment