Skip to content

Render timer results to the console

This operation walks the in-memory CodeTimerItem tree that CreateItems() already built and writes one formatted line per node to the console, indenting each descendant one tab deeper than its parent. It is compiled into the assembly and fully functional, but it is not exposed through the public CodeTimer façade, so a consumer of this library can only reach it by calling CodeTimerResult directly.

Field Value
Operation ID CT-OP-005
Trigger Internal code calls CodeTimerResult.OutputConsole()
Inputs Existing CodeTimerItem tree stored in the current CodeTimerResult instance
Outputs Console text output
Primary components CodeTimerResult.OutputConsole, CodeTimerResult.RecurseConsole, CodeTimerResult.Repeat
Entry point SAIF.Framework.CodeTimer\SAIF.Framework.CodeTimer\CodeTimerResult.cs

Steps

  1. Iterate the root items collection that CreateItems() populated when the enclosing CodeTimerResult was constructed — this is the same tree that XML serialization reads from, so console output and XML output always describe the same underlying data.
  2. Call RecurseConsole(item, 3) for each root-level timer item, seeding the initial indentation at three tab stops.
  3. Build one formatted console line per item, showing its indentation level, quantity, average duration, elapsed total, shortest span, longest span, and the timer's name, so a reader can scan the listing and immediately see both totals and outliers for that timer.
  4. If the current item has children, recurse into each of them with one additional tab level, so the printed listing visually nests descendants beneath their parent in the same shape as the underlying key hierarchy.
  5. Continue until every reachable node in the items tree has produced a console line.

Process flow

The following diagram visualizes this operation's control flow.

flowchart TD
    Start([Console render request]) --> Roots[Iterate root timer items]
    Roots --> WriteLine[Write formatted console line]
    WriteLine --> Children{Child items?}
    Children -->|Yes| Recurse[Render child with deeper indent]
    Children -->|No| Next[Move to next root or child]
    Recurse --> Next
    Next --> Done([Console output complete])

Failure and edge-case behavior

  • This operation is internal-only: the public CodeTimer API never calls it, so it is reachable only through direct, in-assembly use of CodeTimerResult.
  • Unlike XML serialization, console rendering recurses into every child node regardless of the parent's Elapsed value, so a grouping-only node with no measured time of its own still has its children printed.

Sources

  • SAIF.Framework.CodeTimer\SAIF.Framework.CodeTimer\CodeTimerResult.cs
  • SAIF.Framework.CodeTimer\SAIF.Framework.CodeTimer\CodeTimerItem.cs