-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Review benchmark local script and add analyzer * add analyzer env * test analyzer
- Loading branch information
Showing
20 changed files
with
125 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[deps] | ||
BenchmarkProfiles = "ecbce9bc-3e5e-569d-9e29-55181f61f8d0" | ||
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" | ||
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" | ||
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" | ||
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819" | ||
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" | ||
SolverBenchmark = "581a75fa-a23a-52d0-a590-d6201de2218a" | ||
StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using Pkg | ||
Pkg.activate("benchmark/benchmark_analyzer") | ||
Pkg.instantiate() | ||
using BenchmarkTools, Dates, JLD2, JSON, Plots, StatsPlots | ||
|
||
# name of the result file: | ||
name = "" | ||
resultpath = joinpath(dirname(@__FILE__), "results") | ||
if name == "" | ||
name = replace(readdir(resultpath)[end], ".jld2" => "", ".json" => "") | ||
end | ||
|
||
@load joinpath(dirname(@__FILE__), "results", "$name.jld2") result | ||
t = BenchmarkTools.load(joinpath(dirname(@__FILE__), "results", "$name.json")) | ||
|
||
# plots | ||
using StatsPlots | ||
plot(t) # ou can use all the keyword arguments from Plots.jl, for instance st=:box or yaxis=:log10. | ||
|
||
@info "Available benchmarks" | ||
df_results = Dict{String, Dict{Symbol, DataFrame}}() | ||
for benchmark in keys(result) | ||
result_bench = result[benchmark] # one NLPModel API function | ||
for benchmark_list in keys(result_bench) | ||
for type_bench in keys(result_bench[benchmark_list]) | ||
for set_bench in keys(result_bench[benchmark_list][type_bench]) | ||
@info "$benchmark/$benchmark_list for type $type_bench on problem set $(set_bench)" | ||
bench = result_bench[benchmark_list][type_bench][set_bench] | ||
df_results["$(benchmark)_$(benchmark_list)_$(type_bench)_$(set_bench)"] = bg_to_df(bench) | ||
end | ||
end | ||
end | ||
end | ||
|
||
function bg_to_df(bench::BenchmarkGroup) | ||
solvers = collect(keys(bench)) # "jump", ... | ||
nsolvers = length(solvers) | ||
problems = collect(keys(bench[solvers[1]])) | ||
nprob = length(problems) | ||
dfT = Dict{Symbol, DataFrame}() | ||
for solver in solvers | ||
dfT[Symbol(solver)] = DataFrame( | ||
[ | ||
[median(bench[solver][pb]).time for pb in problems], | ||
[median(bench[solver][pb]).memory for pb in problems], | ||
], | ||
[:median_time, :median_memory] | ||
) | ||
end | ||
return dfT | ||
end | ||
|
||
using SolverBenchmark, BenchmarkProfiles | ||
|
||
# b::BenchmarkProfiles.AbstractBackend = PlotsBackend() | ||
costs =[ | ||
df -> df.median_time, | ||
df -> df.median_memory, | ||
] | ||
costnames = ["median time", "median memory"] | ||
for key_benchmark in keys(df_results) | ||
stats = df_results[key_benchmark] | ||
p = profile_solvers(stats, costs, costnames) | ||
savefig(p, "$(name)_$(key_benchmark).png") | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,46 @@ | ||
using Pkg, Logging, JLD2, Dates | ||
using Pkg | ||
Pkg.activate("benchmark") | ||
# instantiate | ||
# up ADNLPModels | ||
Pkg.instantiate() | ||
Pkg.update("ADNLPModels") | ||
using Logging, JLD2, Dates | ||
|
||
path = dirname(@__FILE__) | ||
skip_tune = true | ||
|
||
@info "INITIALIZE" | ||
include("benchmarks.jl") | ||
|
||
list_of_benchmark = keys(SUITE) | ||
# gradient: SUITE[@tagged "grad!"] | ||
# Coloring benchmark: SUITE[@tagged "hessian_backend" || "hessian_residual_backend" || "jacobian_backend" || "jacobian_residual_backend"] | ||
# Matrix benchmark: SUITE[@tagged "hessian_backend" || "hessian_residual_backend" || "jacobian_backend" || "jacobian_residual_backend" || "hess_coord!" || "hess_coord_residual!" || "jac_coord!" || "jac_coord_residual!"] | ||
# Matrix-vector products: SUITE[@tagged "hprod!" || "hprod_residual!" || "jprod!" || "jprod_residual!" || "jtprod!" || "jtprod_residual!"] | ||
|
||
for benchmark_in_suite in list_of_benchmark | ||
@info "$(benchmark_in_suite)" | ||
end | ||
|
||
@info "TUNE" | ||
@time with_logger(ConsoleLogger(Error)) do # remove warnings | ||
tune!(SUITE) | ||
if !skip_tune | ||
@time with_logger(ConsoleLogger(Error)) do | ||
tune!(SUITE) | ||
BenchmarkTools.save("params.json", params(suite)); | ||
end | ||
else | ||
@info "Skip tuning" | ||
# https://juliaci.github.io/BenchmarkTools.jl/dev/manual/ | ||
BenchmarkTools.DEFAULT_PARAMETERS.evals = 1 | ||
end | ||
|
||
@info "RUN" | ||
@time result = with_logger(ConsoleLogger(Error)) do # remove warnings | ||
run(SUITE) | ||
if "params.json" in (path == "" ? readdir() : readdir(path)) | ||
loadparams!(suite, BenchmarkTools.load("params.json")[1], :evals, :samples); | ||
end | ||
run(SUITE, verbose = true) | ||
end | ||
|
||
@info "SAVE BENCHMARK RESULT" | ||
name = "$(today())_adnlpmodels_benchmark" | ||
@save "$name.jld2" result | ||
|
||
@info "ANALYZE" | ||
# save the result in a jld2 file? | ||
# plots | ||
BenchmarkTools.save("$name.json", result) |