-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Thijs Baaijen <[email protected]>
- Loading branch information
Showing
1 changed file
with
24 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,40 @@ | ||
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MPL-2.0 | ||
|
||
from tests.performance._helpers import do_performance_test | ||
|
||
# pylint: disable=missing-function-docstring | ||
|
||
|
||
def perf_test_add_nodes(): | ||
setup_code = { | ||
"grid" : "from power_grid_model_ds import Grid;" | ||
"grid": "from power_grid_model_ds import Grid;" | ||
+ "from power_grid_model_ds._core.model.arrays import NodeArray;" | ||
+ "grid = Grid.empty();" | ||
+ "nodes = NodeArray.zeros({size});" | ||
} | ||
|
||
code_to_test = [ | ||
"grid.append(nodes);" | ||
] | ||
code_to_test = ["grid.append(nodes);"] | ||
|
||
do_performance_test(code_to_test, [10, 1000, 5000], 100, setup_code) | ||
do_performance_test(code_to_test, [10, 200, 1000], 100, setup_code) | ||
|
||
|
||
def perf_test_add_lines(): | ||
setup_code = { | ||
"grid": "from power_grid_model_ds import Grid;" | ||
+ "from power_grid_model_ds._core.model.arrays import NodeArray, LineArray;" | ||
+ "grid = Grid.empty();" | ||
+ "nodes = NodeArray.zeros({size});" | ||
+ "grid.append(nodes);" | ||
+ "lines = LineArray.zeros({size});" | ||
+ "lines.from_node = nodes.id;" | ||
+ "lines.to_node = nodes.id;" | ||
} | ||
|
||
code_to_test = ["grid.append(lines);"] | ||
|
||
do_performance_test(code_to_test, [10, 200, 1000], 100, setup_code) | ||
|
||
|
||
def perf_test_get_downstream_nodes_performance(): | ||
|
@@ -40,5 +57,6 @@ def perf_test_get_downstream_nodes_performance(): | |
|
||
|
||
if __name__ == "__main__": | ||
# perf_test_get_downstream_nodes_performance() | ||
perf_test_get_downstream_nodes_performance() | ||
perf_test_add_nodes() | ||
perf_test_add_lines() |