From 23da250cba01003e6f5cd3db757d8c82e7dfe058 Mon Sep 17 00:00:00 2001 From: Hannes Signer Date: Mon, 24 Jul 2023 18:16:35 +0200 Subject: [PATCH] add easy profiler to CMAKE files --- CMakeLists.txt | 3 ++- examples/CMakeLists.txt | 3 ++- examples/FTCS_2D_proto_example.cpp | 22 +++++++++++++++------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e38161..a980a35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,7 @@ set(CMAKE_CXX_STANDARD 17) find_package(Eigen3 REQUIRED NO_MODULE) find_package(OpenMP) +find_package(easy_profiler REQUIRED) ## SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -mfma") option(TUG_USE_OPENMP "Compile with OpenMP support" ON) @@ -39,4 +40,4 @@ if(TUG_ENABLE_TESTING) add_subdirectory(test) endif() -add_subdirectory(examples) +add_subdirectory(examples) \ No newline at end of file diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index d46ed8f..b806fac 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -6,4 +6,5 @@ add_executable(FTCS_2D_proto_example FTCS_2D_proto_example.cpp) target_link_libraries(first_example tug) target_link_libraries(second_example tug) target_link_libraries(boundary_example1D tug) -target_link_libraries(FTCS_2D_proto_example tug) \ No newline at end of file +target_link_libraries(FTCS_2D_proto_example tug) +target_link_libraries(FTCS_2D_proto_example easy_profiler) \ No newline at end of file diff --git a/examples/FTCS_2D_proto_example.cpp b/examples/FTCS_2D_proto_example.cpp index dec4e34..1490ac5 100644 --- a/examples/FTCS_2D_proto_example.cpp +++ b/examples/FTCS_2D_proto_example.cpp @@ -7,13 +7,17 @@ */ #include +#include +#define EASY_PROFILER_ENABLE ::profiler::setEnabled(true); + int main(int argc, char *argv[]) { - + EASY_PROFILER_ENABLE; + profiler::startListen(); // ************** // **** GRID **** // ************** - + profiler::startListen(); // create a grid with a 20 x 20 field int row = 20; int col = 20; @@ -25,8 +29,8 @@ int main(int argc, char *argv[]) { // (optional) set the concentrations, e.g.: // MatrixXd concentrations = MatrixXd::Constant(20,20,1000); // #row,#col,value // grid.setConcentrations(concentrations); - MatrixXd concentrations = MatrixXd::Constant(20,20,0); - // concentrations(0,0) = 2000; + MatrixXd concentrations = MatrixXd::Constant(row, col,1); + concentrations(0,0) = 2000; grid.setConcentrations(concentrations); // (optional) set alphas of the grid, e.g.: @@ -64,14 +68,18 @@ int main(int argc, char *argv[]) { simulation.setTimestep(0.1); // timestep // (optional) set the number of iterations - simulation.setIterations(1000); + simulation.setIterations(2); // (optional) set kind of output [CSV_OUTPUT_OFF (default), CSV_OUTPUT_ON, CSV_OUTPUT_VERBOSE] simulation.setOutputCSV(CSV_OUTPUT_VERBOSE); // **** RUN SIMULATION **** - + // run the simulation - simulation.run(); + EASY_BLOCK("SIMULATION") + simulation.run(); + EASY_END_BLOCK; + profiler::dumpBlocksToFile("test_profile.prof"); + profiler::stopListen(); } \ No newline at end of file