Skip to content

Commit

Permalink
Add test for timed section interruption idaholab#23746
Browse files Browse the repository at this point in the history
  • Loading branch information
GiudGiud committed Mar 20, 2024
1 parent a347bd0 commit 8cf93f2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions test/include/problems/SlowProblem.h
Expand Up @@ -30,5 +30,6 @@ class SlowProblem : public FEProblem

const std::vector<Real> _seconds_to_sleep;
const bool _nested_print;
const bool _nested_print_end;
const bool _nested_section;
};
13 changes: 12 additions & 1 deletion test/src/problems/SlowProblem.C
Expand Up @@ -25,6 +25,9 @@ SlowProblem::validParams()
// Parameters to print perf graph live print interactions
params.addParam<bool>(
"print_during_section", false, "Whether to nest a console print inside the timed section");
params.addParam<bool>("print_at_end_of_section",
false,
"Whether to nest a console print right at the end of the timed section");
params.addParam<bool>(
"nest_inside_section", false, "Whether to nest another section inside the timed section");

Expand All @@ -35,6 +38,7 @@ SlowProblem::SlowProblem(const InputParameters & params)
: FEProblem(params),
_seconds_to_sleep(getParam<std::vector<Real>>("seconds_to_sleep")),
_nested_print(getParam<bool>("print_during_section")),
_nested_print_end(getParam<bool>("print_at_end_of_section")),
_nested_section(getParam<bool>("nest_inside_section"))
{
if (_seconds_to_sleep.empty())
Expand All @@ -52,12 +56,18 @@ SlowProblem::solve(unsigned int nl_sys_num)
TIME_SECTION("slow", 1, "Testing Slowness");
std::this_thread::sleep_for(std::chrono::duration<Real>(delay));
}
else if (_nested_print)
else if (_nested_print_end)
{
TIME_SECTION("slow", 1, "Testing Slowness");
_console << "Timed section just started, printing something though" << std::endl;
std::this_thread::sleep_for(std::chrono::duration<Real>(delay));
}
else if (_nested_print)
{
TIME_SECTION("slow", 1, "Testing Slowness");
std::this_thread::sleep_for(std::chrono::duration<Real>(delay));
_console << "Timed section is about to finish" << std::endl;
}
else if (_nested_section)
{
TIME_SECTION("slow", 1, "Testing Slowness");
Expand All @@ -74,6 +84,7 @@ SlowProblem::otherTimedSection() const
{
Real delay = getDelay();
TIME_SECTION("slowish", 2, "Testing Nested Slowness");
_console << "Interrupt" << std::endl;
std::this_thread::sleep_for(std::chrono::duration<Real>(delay));
}

Expand Down
11 changes: 11 additions & 0 deletions test/tests/utils/perf_graph_live_print/tests
Expand Up @@ -31,6 +31,17 @@
design = 'utils/PerfGraphLivePrint.md'
requirement = 'The system shall be able to display the automatic print-out of a timed section even when an external print happened before the threshold for the automatic print-out was met.'
[]
[stats_interrupted_by_regular_print]
# this test does not address the warnings 'direct to Moose::out' issue #23750
type = RunApp
input = perf_graph_live_print.i
cli_args = 'Problem/print_at_end_of_section=true'
expect_out = "Timed section is about to finish\nFinished"

issues = '#23746'
design = 'utils/PerfGraphLivePrint.md'
requirement = 'The system shall be able to display the automatic print-out of a timed section even when an external print happened right at the end of the timed section, before the statistics for the sections were printed.'
[]

[multiapps]
type = RunApp
Expand Down

0 comments on commit 8cf93f2

Please sign in to comment.