Skip to content

Commit

Permalink
add perf test for add_lines
Browse files Browse the repository at this point in the history
Signed-off-by: Thijs Baaijen <[email protected]>
  • Loading branch information
Thijss committed Feb 3, 2025
1 parent 9800bfe commit 6278ede
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions tests/performance/grid_performance_tests.py
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():
Expand All @@ -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()

0 comments on commit 6278ede

Please sign in to comment.