From 7d7265db754402bdc57ac21a41097f4f34db635c Mon Sep 17 00:00:00 2001 From: Derek Gaston Date: Wed, 11 Aug 2021 13:59:46 -0600 Subject: [PATCH] Test PerfGraphLivePrint refs #15444 --- framework/src/actions/Action.C | 1 - framework/src/outputs/ConsoleUtils.C | 5 +- framework/src/utils/PerfGraphRegistry.C | 3 -- framework/src/utils/SystemInfo.C | 2 +- test/include/problems/SlowProblem.h | 27 ++++++++++ test/src/problems/SlowProblem.C | 41 ++++++++++++++++ .../perf_graph_live_print.i | 49 +++++++++++++++++++ test/tests/utils/perf_graph_live_print/tests | 11 +++++ 8 files changed, 131 insertions(+), 8 deletions(-) create mode 100644 test/include/problems/SlowProblem.h create mode 100644 test/src/problems/SlowProblem.C create mode 100644 test/tests/utils/perf_graph_live_print/perf_graph_live_print.i create mode 100644 test/tests/utils/perf_graph_live_print/tests diff --git a/framework/src/actions/Action.C b/framework/src/actions/Action.C index faca90401fe2..d33ad0729ae8 100644 --- a/framework/src/actions/Action.C +++ b/framework/src/actions/Action.C @@ -89,7 +89,6 @@ Action::Action(InputParameters parameters) void Action::timedAct() { - _console << "act_timer: " << _act_timer << std::endl; TIME_SECTION(_act_timer); act(); } diff --git a/framework/src/outputs/ConsoleUtils.C b/framework/src/outputs/ConsoleUtils.C index 8e87be417740..f60426e6a4eb 100644 --- a/framework/src/outputs/ConsoleUtils.C +++ b/framework/src/outputs/ConsoleUtils.C @@ -45,8 +45,7 @@ outputFrameworkInformation(const MooseApp & app) << std::setw(console_field_width) << " Num Processors: " << static_cast(app.n_processors()) << '\n' << std::setw(console_field_width) - << " Num Threads: " << static_cast(libMesh::n_threads()) << '\n' - << std::endl; + << " Num Threads: " << static_cast(libMesh::n_threads()) << std::endl; return oss.str(); } @@ -66,7 +65,7 @@ outputMeshInformation(FEProblemBase & problem, bool verbose) bool pre_split = problem.getMooseApp().isUseSplit(); // clang-format off - oss << "\n\nMesh: " << '\n' + oss << "\nMesh: " << '\n' << std::setw(console_field_width) << " Parallel Type: " << (moose_mesh.isDistributedMesh() ? "distributed" : "replicated") << (forced || pre_split ? " (" : "") diff --git a/framework/src/utils/PerfGraphRegistry.C b/framework/src/utils/PerfGraphRegistry.C index 082f2ccde558..d2ad4ec18be7 100644 --- a/framework/src/utils/PerfGraphRegistry.C +++ b/framework/src/utils/PerfGraphRegistry.C @@ -58,9 +58,6 @@ PerfGraphRegistry::actuallyRegisterSection(const std::string & section_name, _section_name_to_id.emplace(section_name, id); } - if (id == 4) - libMesh::out << "ID4: " << section_name << std::endl; - { std::lock_guard lock(_id_to_section_info_mutex); diff --git a/framework/src/utils/SystemInfo.C b/framework/src/utils/SystemInfo.C index d9036ee6d8ae..dbf4038f970a 100644 --- a/framework/src/utils/SystemInfo.C +++ b/framework/src/utils/SystemInfo.C @@ -26,7 +26,7 @@ std::string SystemInfo::getInfo() const { std::stringstream oss; - oss << std::left << "\n\nFramework Information:\n" + oss << std::left << "Framework Information:\n" << std::setw(25) << "MOOSE Version: " << MOOSE_REVISION << '\n' << std::setw(25) << "LibMesh Version: " << LIBMESH_BUILD_VERSION << '\n'; #ifdef LIBMESH_DETECTED_PETSC_VERSION_MAJOR diff --git a/test/include/problems/SlowProblem.h b/test/include/problems/SlowProblem.h new file mode 100644 index 000000000000..7bbfb94138a7 --- /dev/null +++ b/test/include/problems/SlowProblem.h @@ -0,0 +1,27 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#pragma once + +#include "FEProblem.h" + +/** + * FEProblemBase derived class for testing out PerfGraph + */ +class SlowProblem : public FEProblem +{ +public: + static InputParameters validParams(); + + SlowProblem(const InputParameters & params); + virtual void solve(); + +protected: + unsigned int _seconds_to_sleep; +}; diff --git a/test/src/problems/SlowProblem.C b/test/src/problems/SlowProblem.C new file mode 100644 index 000000000000..cf20f55d030f --- /dev/null +++ b/test/src/problems/SlowProblem.C @@ -0,0 +1,41 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#include "SlowProblem.h" + +#include "MooseApp.h" + +#include +#include + +registerMooseObject("MooseTestApp", SlowProblem); + +InputParameters +SlowProblem::validParams() +{ + InputParameters params = FEProblem::validParams(); + params.addRequiredParam("seconds_to_sleep", "The number of seconds to sleep"); + return params; +} + +SlowProblem::SlowProblem(const InputParameters & params) + : FEProblem(params), _seconds_to_sleep(getParam("seconds_to_sleep")) +{ +} + +void +SlowProblem::solve() +{ + { + TIME_SECTION("slow", 1, "Testing Slowness"); + std::this_thread::sleep_for(std::chrono::seconds(_seconds_to_sleep)); + } + + FEProblem::solve(); +} diff --git a/test/tests/utils/perf_graph_live_print/perf_graph_live_print.i b/test/tests/utils/perf_graph_live_print/perf_graph_live_print.i new file mode 100644 index 000000000000..f95870450963 --- /dev/null +++ b/test/tests/utils/perf_graph_live_print/perf_graph_live_print.i @@ -0,0 +1,49 @@ +[Mesh] + type = GeneratedMesh + dim = 2 + nx = 10 + ny = 10 +[] + +[Variables] + [u] + [] +[] + +[Kernels] + [diff] + type = Diffusion + variable = u + [] +[] + +[BCs] + [left] + type = DirichletBC + variable = u + boundary = left + value = 0 + [] + [right] + type = DirichletBC + variable = u + boundary = right + value = 1 + [] +[] + +[Problem] + type = SlowProblem + seconds_to_sleep = 4 +[] + +[Executioner] + type = Steady + solve_type = 'PJFNK' + petsc_options_iname = '-pc_type -pc_hypre_type' + petsc_options_value = 'hypre boomeramg' +[] + +[Outputs] + exodus = true +[] diff --git a/test/tests/utils/perf_graph_live_print/tests b/test/tests/utils/perf_graph_live_print/tests new file mode 100644 index 000000000000..13ec05022b65 --- /dev/null +++ b/test/tests/utils/perf_graph_live_print/tests @@ -0,0 +1,11 @@ +[Tests] + [./test] + type = RunApp + input = perf_graph_live_print.i + expect_out = "Testing Slowness" + + issues = '#15444' + design = 'utils/PerfGraph.md' + requirement = 'The system shall allow for timing sections of code and having automated print-outs when they take too long or use too much memory' + [../] +[]