Skip to content

Commit

Permalink
Use Norse data on the benchmarks (#171)
Browse files Browse the repository at this point in the history
* Fix benchmarks.jl and use Norse data

* Add a test to load the benchmarks.jl to ensure at least syntax correctness
  • Loading branch information
abelsiqueira authored Oct 24, 2023
1 parent 4e5bbdd commit 308b90e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
17 changes: 11 additions & 6 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ using TulipaEnergyModel

const SUITE = BenchmarkGroup()

SUITE["io"] = BenchmarkGroup(["data", "input", "graph", "output"])
SUITE["model"] = BenchmarkGroup(["model"])
SUITE["io"] = BenchmarkGroup()
SUITE["model"] = BenchmarkGroup()

const INPUT_FOLDER = joinpath(@__DIR__, "..", "test", "inputs", "tiny")
const INPUT_FOLDER = joinpath(@__DIR__, "..", "test", "inputs", "Norse")
const OUTPUT_FOLDER = joinpath(@__DIR__, "..", "test", "outputs")

SUITE["io"]["input"] = @benchmarkable begin
Expand All @@ -25,18 +25,23 @@ graph = create_graph(
joinpath(INPUT_FOLDER, "flows-data.csv"),
)

SUITE["model"]["all"] = @benchmarkable begin
SUITE["model"]["create_model"] = @benchmarkable begin
create_model($graph, $parameters, $sets)
end

model = create_model(graph, parameters, sets)

SUITE["model"]["solve_model"] = @benchmarkable begin
solve_model($model)
end

solution = solve_model(model)

SUITE["io"]["output"] = @benchmarkable begin
save_solution_to_file(
$OUTPUT_FOLDER,
$(sets.assets_investment),
$(solution.v_investment),
$(parameters.unit_capacity),
$(solution.assets_investment),
$(parameters.assets_unit_capacity),
)
end
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
Expand Down
5 changes: 5 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,8 @@ end
@test compute_rp_periods([time_steps4, time_steps5]) == [1:6, 7:12]
end
end

@testset "Ensuring benchmark loads" begin
include(joinpath(@__DIR__, "..", "benchmark", "benchmarks.jl"))
@test SUITE !== nothing
end

0 comments on commit 308b90e

Please sign in to comment.