PerfGraphReporterReader

A python utility that provides an interface for reading PerfGraphReporter output. It rebuilds the graph for easy traversal via the PerfGraphNode and PerfGraphSection objects.

Example usage

Take the following simple diffusion problem, which has a PerfGraphReporter set to output on final:

[Mesh<<<{"href": "../../syntax/Mesh/index.html"}>>>]
  [gmg]
    type = GeneratedMeshGenerator<<<{"description": "Create a line, square, or cube mesh with uniformly spaced or biased elements.", "href": "../../source/meshgenerators/GeneratedMeshGenerator.html"}>>>
    dim<<<{"description": "The dimension of the mesh to be generated"}>>> = 2
    nx<<<{"description": "Number of elements in the X direction"}>>> = 1
    ny<<<{"description": "Number of elements in the Y direction"}>>> = 1
  []
[]

[Variables<<<{"href": "../../syntax/Variables/index.html"}>>>/u]
[]

[Kernels<<<{"href": "../../syntax/Kernels/index.html"}>>>/diff]
  type = Diffusion<<<{"description": "The Laplacian operator ($-\\nabla \\cdot \\nabla u$), with the weak form of $(\\nabla \\phi_i, \\nabla u_h)$.", "href": "../../source/kernels/Diffusion.html"}>>>
  variable<<<{"description": "The name of the variable that this residual object operates on"}>>> = u
[]

[BCs<<<{"href": "../../syntax/BCs/index.html"}>>>]
  [left]
    type = DirichletBC<<<{"description": "Imposes the essential boundary condition $u=g$, where $g$ is a constant, controllable value.", "href": "../../source/bcs/DirichletBC.html"}>>>
    variable<<<{"description": "The name of the variable that this residual object operates on"}>>> = u
    boundary<<<{"description": "The list of boundary IDs from the mesh where this object applies"}>>> = left
    value<<<{"description": "Value of the BC"}>>> = 0
  []
  [right]
    type = DirichletBC<<<{"description": "Imposes the essential boundary condition $u=g$, where $g$ is a constant, controllable value.", "href": "../../source/bcs/DirichletBC.html"}>>>
    variable<<<{"description": "The name of the variable that this residual object operates on"}>>> = u
    boundary<<<{"description": "The list of boundary IDs from the mesh where this object applies"}>>> = right
    value<<<{"description": "Value of the BC"}>>> = 1
  []
[]

[Executioner<<<{"href": "../../syntax/Executioner/index.html"}>>>]
  type = Steady
  solve_type = 'PJFNK'
  petsc_options_iname = '-pc_type -pc_hypre_type'
  petsc_options_value = 'hypre boomeramg'
[]

[Reporters<<<{"href": "../../syntax/Reporters/index.html"}>>>/perf_graph]
  type = PerfGraphReporter<<<{"description": "Reports the full performance graph from the PerfGraph.", "href": "../../source/reporters/PerfGraphReporter.html"}>>>
  execute_on<<<{"description": "The list of flag(s) indicating when this object should be executed. For a description of each flag, see https://mooseframework.inl.gov/source/interfaces/SetupInterface.html."}>>> = FINAL
[]

[Outputs<<<{"href": "../../syntax/Outputs/index.html"}>>>/json]
  type = JSON<<<{"description": "Output for Reporter values using JSON format.", "href": "../../source/outputs/JSONOutput.html"}>>>
  execute_on<<<{"description": "The list of flag(s) indicating when this object should be executed. For a description of each flag, see https://mooseframework.inl.gov/source/interfaces/SetupInterface.html."}>>> = 'INITIAL FINAL'
[]
(test/tests/reporters/perf_graph_reporter/perf_graph_reporter.i)

For more real-world-like timing, we will pass the command line arguments "Mesh/gmg/nx=500 Mesh/gmg/ny=500", as the test above is executed with only a single element. With this, we will execute the following (where MOOSE_DIR is an environment variable set to the directory that contains MOOSE):

$MOOSE_DIR/test/moose_test-opt -i $MOOSE_DIR/test/tests/reporters/perf_graph_reporter/perf_graph_reporter.i Mesh/gmg/nx=500 Mesh/gmg/ny=500

This run will generate the desired output in $MOOSE_DIR/test/tests/reporters/perf_graph_reporter/perf_graph_reporter_json.json.

Load a PerfGraphReporterReader with the given output as such:

import os
from mooseutils.PerfGraphReporterReader import PerfGraphReporterReader
MOOSE_DIR = os.environ.get('MOOSE_DIR')
pgrr = PerfGraphReporterReader(MOOSE_DIR + '/test/tests/reporters/perf_graph_reporter/perf_graph_reporter_json.json')