Skip to content

Commit

Permalink
Add coarse top-level timing profile output
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilMiller committed Jan 5, 2024
1 parent afa7de5 commit 6c8cb15
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/NGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <fstream>
#include <string>
#include <unordered_map>
#include <chrono>

#include <utilities/span.hpp>

Expand Down Expand Up @@ -154,6 +155,8 @@ int main(int argc, char *argv[]) {
exit(1);
}

auto time_start = std::chrono::steady_clock::now();

std::cout << "NGen Framework " << ngen_VERSION_MAJOR << "."
<< ngen_VERSION_MINOR << "."
<< ngen_VERSION_PATCH << std::endl;
Expand Down Expand Up @@ -485,6 +488,9 @@ int main(int argc, char *argv[]) {

}

auto time_done_init = std::chrono::steady_clock::now();
std::chrono::duration<double> time_elapsed_init = time_done_init - time_start;

//Now loop some time, iterate catchments, do stuff for total number of output times
auto num_times = manager->Simulation_Time_Object->get_total_output_times();
for( int count = 0; count < num_times; count++)
Expand Down Expand Up @@ -546,6 +552,8 @@ int main(int argc, char *argv[]) {
std::cout << "Finished " << manager->Simulation_Time_Object->get_total_output_times() << " timesteps." << std::endl;
}

auto time_done_simulation = std::chrono::steady_clock::now();
std::chrono::duration<double> time_elapsed_simulation = time_done_simulation - time_done_init;

#ifdef NGEN_MPI_ACTIVE
MPI_Barrier(MPI_COMM_WORLD);
Expand All @@ -568,6 +576,20 @@ int main(int argc, char *argv[]) {
}
#endif

auto time_done_routing = std::chrono::steady_clock::now();
std::chrono::duration<double> time_elapsed_routing = time_done_routing - time_done_simulation;

if (mpi_rank == 0)
{
std::cout << "NGen top-level timings:"
<< "\n\tNGen::init: " << time_elapsed_init.count()
<< "\n\tNGen::simulation: " << time_elapsed_simulation.count()
#ifdef NGEN_ROUTING_ACTIVE
<< "\n\tNGen::routing: " << time_elapsed_routing.count()
#endif
<< std::endl;
}

#ifdef NGEN_MPI_ACTIVE
MPI_Finalize();
#endif
Expand Down

0 comments on commit 6c8cb15

Please sign in to comment.