121using FvCounts = std::array<long, n_fv_counter_count>;
178 "[PERF-FV] step=%.4f total=%.4f "
179 "census=%.4f flux=%.4f nodesolve=%.4f positivity=%.4f "
180 "cellupdate=%.4f nodeupdate=%.4f refreshdepths=%.4f "
181 "savestate=%.4f restore=%.4f structrefresh=%.4f bndcallback=%.4f "
182 "rebuild=%.4f reconstruct=%.4f ltsfire=%.4f settle=%.4f tier=%.4f "
183 "n.substep=%ld n.census=%ld n.censusface=%ld n.invert=%ld "
184 "n.savestate=%ld n.rollback=%ld n.structrefresh=%ld "
185 "n.algvisit=%ld n.algpassthru=%ld n.algsolve=%ld "
186 "n.algresidual=%ld n.algfaceflux=%ld "
187 "n.area=%ld n.width=%ld n.i1=%ld n.hydrad=%ld "
188 "n.macro=%ld n.macrorej=%ld "
189 "passthru_frac=%.4f rollback_frac=%.4f "
190 "algresid_per_solve=%.2f algflux_per_solve=%.2f\n",
218inline std::chrono::steady_clock::time_point
now() noexcept {
219 return std::chrono::steady_clock::now();
227inline double since(std::chrono::steady_clock::time_point t0)
noexcept {
228 return std::chrono::duration<double>(
now() - t0).count();
239 static const bool on = (std::getenv(
"OPENSWMM_PERF") !=
nullptr);
268 const double open_total =
274 "[PERF-LOAD] open=%.4f open.prescan2d=%.4f open.read=%.4f "
275 "read.scan=%.4f read.dispatch=%.4f "
276 "open.resolve=%.4f open.validate=%.4f "
277 "res.extfiles=%.4f res.tables=%.4f res.transects=%.4f res.xsect=%.4f "
279 "init=%.4f init.state=%.4f init.hydraulics=%.4f init.hydrology=%.4f "
280 "init.quality=%.4f init.geometry=%.4f "
281 "start=%.4f start.iface=%.4f start.plugins=%.4f\n",
292 std::chrono::steady_clock::time_point
t0;
302 explicit ScopedTimer(
double& a) noexcept :
acc(&a),
t0(std::chrono::steady_clock::now()) {}
309 *
acc += std::chrono::duration<double>(std::chrono::steady_clock::now() -
t0).count();
361 std::chrono::steady_clock::time_point
t0;
377 t0 = std::chrono::steady_clock::now();
391 std::chrono::duration<double>(std::chrono::steady_clock::now() -
t0).count();
448 for (std::size_t i = 0; i < local_.size(); ++i)
449 (*previous_)[i] += local_[i];
452 for (std::size_t i = 0; i < local_.size(); ++i)
484 (*local_fv_counts)[counter] += n;
CounterBatch() noexcept
Install private FV counters for the current worker when profiling is enabled.
Definition PerfTimers.hpp:430
~CounterBatch() noexcept
Merge private counters into the enclosing batch or completed totals.
Definition PerfTimers.hpp:443
CounterBatch(const CounterBatch &)=delete
Prevent copying an active CounterBatch scope.
CounterBatch & operator=(const CounterBatch &)=delete
Prevent replacing an active CounterBatch scope by copy assignment.
Definition PerfTimers.hpp:26
double sec_res_tables
Definition PerfTimers.hpp:51
FvCounter
Definition PerfTimers.hpp:100
@ n_fv_geom_hydrad
Definition PerfTimers.hpp:116
@ n_fv_alg_visit
Definition PerfTimers.hpp:108
@ n_fv_substep
Definition PerfTimers.hpp:101
@ n_fv_macro_cycles
Definition PerfTimers.hpp:117
@ n_fv_savestate
Definition PerfTimers.hpp:105
@ n_fv_alg_passthru
Definition PerfTimers.hpp:109
@ n_fv_census_face
Definition PerfTimers.hpp:103
@ n_fv_counter_count
Definition PerfTimers.hpp:119
@ n_fv_alg_solve
Definition PerfTimers.hpp:110
@ n_fv_structref
Definition PerfTimers.hpp:107
@ n_fv_restore
Definition PerfTimers.hpp:106
@ n_fv_macro_rejected
Definition PerfTimers.hpp:118
@ n_fv_invert
Definition PerfTimers.hpp:104
@ n_fv_geom_i1
Definition PerfTimers.hpp:115
@ n_fv_alg_flux
Definition PerfTimers.hpp:112
@ n_fv_geom_area
Definition PerfTimers.hpp:113
@ n_fv_census
Definition PerfTimers.hpp:102
@ n_fv_geom_width
Definition PerfTimers.hpp:114
@ n_fv_alg_resid
Definition PerfTimers.hpp:111
long value(FvCounter counter) noexcept
Read one process-global completed FV counter total.
Definition PerfTimers.hpp:136
double sec_open_read
Definition PerfTimers.hpp:40
thread_local double nested_wall
ScopedTimer that reads the clock only when OPENSWMM_PERF is set.
Definition PerfTimers.hpp:356
void reset_load() noexcept
Zero load/open/initialize/start phase accumulators.
Definition PerfTimers.hpp:249
double sec_fv_cellupdate
Definition PerfTimers.hpp:85
double sec_init_hydrology
Definition PerfTimers.hpp:58
double sec_init_hydraulics
Definition PerfTimers.hpp:57
double sec_read_dispatch
Definition PerfTimers.hpp:44
double sec_fv_ltsfire
Definition PerfTimers.hpp:94
double sec_fv_nodesolve
Definition PerfTimers.hpp:83
double sec_fv_bndcallback
Definition PerfTimers.hpp:91
double sec_2d_advance
Definition PerfTimers.hpp:29
double sec_res_extfiles
Definition PerfTimers.hpp:50
bool enabled() noexcept
Read the process-cached profiling environment gate.
Definition PerfTimers.hpp:238
double sec_start_iface
Definition PerfTimers.hpp:62
void reset_fv() noexcept
Zero FV phase timers and completed counter totals.
Definition PerfTimers.hpp:146
double sec_fv_reconstruct
Definition PerfTimers.hpp:93
thread_local FvCounts * local_fv_counts
Definition PerfTimers.hpp:123
double sec_res_xsect
Definition PerfTimers.hpp:53
std::array< long, n_fv_counter_count > FvCounts
Definition PerfTimers.hpp:121
double sec_open_validate
Definition PerfTimers.hpp:46
double sec_fv_restore
Definition PerfTimers.hpp:89
double sec_init_geometry
Definition PerfTimers.hpp:60
double sec_fv_settle
Definition PerfTimers.hpp:95
void dump_fv() noexcept
One machine-scrapeable line for the FV phase split.
Definition PerfTimers.hpp:170
std::chrono::steady_clock::time_point now() noexcept
Sample the steady monotonic clock regardless of profiling enablement.
Definition PerfTimers.hpp:218
std::mutex fv_counts_mutex
Definition PerfTimers.hpp:124
double sec_fv_structref
Definition PerfTimers.hpp:90
double sec_start_plugins
Definition PerfTimers.hpp:63
double sec_fv_tier
Definition PerfTimers.hpp:96
double sec_res_shrink
Definition PerfTimers.hpp:54
double sec_2d_window
Definition PerfTimers.hpp:28
double sec_fv_flux
Definition PerfTimers.hpp:82
double sec_fv_positivity
Definition PerfTimers.hpp:84
double sec_open_prescan2d
Definition PerfTimers.hpp:39
void dump_load() noexcept
One machine-scrapeable line per phase on stderr.
Definition PerfTimers.hpp:267
@ count
Definition ProcessPerf.hpp:26
double sec_fv_savestate
Definition PerfTimers.hpp:88
double sec_init_quality
Definition PerfTimers.hpp:59
double sec_res_transects
Definition PerfTimers.hpp:52
double sec_fv_refreshdep
Definition PerfTimers.hpp:87
double since(std::chrono::steady_clock::time_point t0) noexcept
Measure elapsed wall time from a steady-clock sample.
Definition PerfTimers.hpp:227
double sec_fv_rebuild
Definition PerfTimers.hpp:92
FvCounts fv_counts
Definition PerfTimers.hpp:122
double sec_fv_nodeupdate
Definition PerfTimers.hpp:86
double sec_fv_census
Definition PerfTimers.hpp:81
double sec_open_resolve
Definition PerfTimers.hpp:45
double sec_1d_step
Definition PerfTimers.hpp:30
double sec_init_state
Definition PerfTimers.hpp:56
double outer
enclosing timer's tally, restored on close
Definition PerfTimers.hpp:360
GatedTimer & operator=(const GatedTimer &)=delete
Prevent replacing an active GatedTimer scope by copy assignment.
double * acc
Definition PerfTimers.hpp:359
~GatedTimer() noexcept
Add elapsed wall time excluding nested GatedTimer intervals.
Definition PerfTimers.hpp:387
std::chrono::steady_clock::time_point t0
Definition PerfTimers.hpp:361
GatedTimer(const GatedTimer &)=delete
Prevent copying an active GatedTimer scope.
GatedTimer(double &a) noexcept
Start a profiling-gated self-time interval on the current thread.
Definition PerfTimers.hpp:372
ScopedTimer(const ScopedTimer &)=delete
Prevent copying an active ScopedTimer scope.
ScopedTimer(double &a) noexcept
Start an unconditional wall timer against a borrowed accumulator.
Definition PerfTimers.hpp:302
std::chrono::steady_clock::time_point t0
Definition PerfTimers.hpp:292
~ScopedTimer() noexcept
Add complete elapsed wall seconds to the borrowed accumulator.
Definition PerfTimers.hpp:308
ScopedTimer & operator=(const ScopedTimer &)=delete
Prevent replacing an active ScopedTimer scope by copy assignment.
double * acc
Definition PerfTimers.hpp:291