From f48e4d9de5ba2b6e33dbc2ea173147ad6aad3db5 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Tue, 18 Feb 2025 16:27:19 +0100 Subject: [PATCH 1/4] Add experimental profiling API from precice/precice #1657 --- cyprecice/Participant.pxd | 5 +++++ cyprecice/cyprecice.pyx | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/cyprecice/Participant.pxd b/cyprecice/Participant.pxd index 01614ce0..65911eac 100644 --- a/cyprecice/Participant.pxd +++ b/cyprecice/Participant.pxd @@ -87,6 +87,11 @@ cdef extern from "precice/Participant.hpp" namespace "precice": void writeGradientData(const string& meshName, const string& dataName, vector[int] vertices, vector[double] gradientValues) + # Experimental profiling API + + void startProfilingSection(const string& eventName) + + void stopLastProfilingSection() cdef extern from "precice/Tooling.hpp" namespace "precice": string getVersionInformation() diff --git a/cyprecice/cyprecice.pyx b/cyprecice/cyprecice.pyx index 3349fead..2b11aca4 100644 --- a/cyprecice/cyprecice.pyx +++ b/cyprecice/cyprecice.pyx @@ -1080,6 +1080,23 @@ cdef class Participant: return np_ids, np_coordinates.reshape((size, dimensions)) + def start_profiling_section(self, event_name): + """ + Starts a profiling section with the given event name. + + Parameters + ---------- + event_name : str + Name of the event to profile. + """ + self.thisptr.startProfilingSection(convert(event_name)) + + def stop_last_profiling_section(self): + """ + Stops the last profiling section. + """ + self.thisptr.stopLastProfilingSection() + def get_version_information (): """ Returns From aeb3ec365d942ec2088c016e994e95034e393ce8 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Tue, 11 Mar 2025 16:55:27 +0530 Subject: [PATCH 2/4] Add examples to the profiling API docstrings --- cyprecice/cyprecice.pyx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cyprecice/cyprecice.pyx b/cyprecice/cyprecice.pyx index 2b11aca4..f7a598d3 100644 --- a/cyprecice/cyprecice.pyx +++ b/cyprecice/cyprecice.pyx @@ -1087,13 +1087,24 @@ cdef class Participant: Parameters ---------- event_name : str - Name of the event to profile. + Name of the event to profile. + + Examples + -------- + Start a profiling section with the event name "EventOne": + >>> event_name = "EventOne" + >>> participant.start_profiling_section(event_name) """ self.thisptr.startProfilingSection(convert(event_name)) def stop_last_profiling_section(self): """ Stops the last profiling section. + + Examples + -------- + Stop the last profiling section: + >>> participant.stop_last_profiling_section() """ self.thisptr.stopLastProfilingSection() From 2d4cf0eb4a6862ba175103c01e9c73d6e7ce3227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Simonis?= Date: Fri, 14 Mar 2025 11:45:15 +0100 Subject: [PATCH 3/4] Add profiling API to mock --- test/Participant.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/Participant.cpp b/test/Participant.cpp index 74107e9c..03b4741e 100644 --- a/test/Participant.cpp +++ b/test/Participant.cpp @@ -320,6 +320,15 @@ void Participant::writeGradientData( } } +void Participant::startProfilingSection( + precice::string_view sectionName) +{ +} + +void Participant::stopLastProfilingSection() +{ +} + std::string getVersionInformation() { return fake_version; From 2e63ee0770b9b66755684427dd38331bbf3cb8a7 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Fri, 14 Mar 2025 16:23:37 +0100 Subject: [PATCH 4/4] Add CHANGELOG entry --- changelog-entries/226.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog-entries/226.md diff --git a/changelog-entries/226.md b/changelog-entries/226.md new file mode 100644 index 00000000..3fb64908 --- /dev/null +++ b/changelog-entries/226.md @@ -0,0 +1 @@ +- Added profiling API which was introduced in preCICE in https://github.com/precice/precice/pull/1657