TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
Runtime utilities

Detailed Description

Timers, signal handling, crash logging and other runtime helpers.

Namespaces

namespace  triqs::signal_handler
 Signal handling utilities for the TRIQS library.

Classes

class  triqs::utility::crash_logger
 RAII helper that writes user-registered objects to an HDF5 crash dump on abnormal scope exit. More...
class  triqs::utility::timer
 Accumulating wall-clock timer based on std::chrono::high_resolution_clock. More...

Functions

std::function< bool()> triqs::utility::clock_callback (int time_in_seconds)
 Build a callback that returns true once a given time in seconds has elapsed since its creation.
std::string triqs::utility::estimate_time_left (int N, int n, timer &t)
 Linear extrapolation of the remaining time of a loop, formatted as HH:MM:SS.
std::string triqs::utility::hours_minutes_seconds_from_seconds (double sec)
 Format an absolute number of seconds as HH:MM:SS.
std::string triqs::utility::stack_trace ()
 Capture the current call stack and return it as a demangled, human-readable string.
std::string triqs::utility::timestamp ()
 Current local time formatted as HH:MM:SS.

Function Documentation

◆ clock_callback()

std::function< bool()> triqs::utility::clock_callback ( int time_in_seconds)

#include <triqs/utility/callbacks.cpp>

Build a callback that returns true once a given time in seconds has elapsed since its creation.

Typically used as a stop condition for long-running loops (Monte Carlo cycles, optimisers, ...). The first invocation starts the internal clock. Subsequent invocations check the elapsed wall-clock time.

Parameters
time_in_secondsWall-clock budget in seconds.
Returns
A std::function<bool()> that returns true once the budget is exhausted.

Definition at line 28 of file callbacks.cpp.

◆ estimate_time_left()

std::string triqs::utility::estimate_time_left ( int N,
int n,
timer & t )
inline

#include <triqs/utility/timestamp.hpp>

Linear extrapolation of the remaining time of a loop, formatted as HH:MM:SS.

It uses the provided (running) timer to estimate \( \eta = (N - 1 - n) * t / (n + 1) \), where \(N \) is the total number of iterations, \( n \) is the current iteration index (zero-based), and \( t \) is the total elapsed time so far.

Parameters
NTotal number of iterations the loop will perform.
nIndex of the current iteration (zero-based).
tRunning timer covering the iterations so far.
Returns
Estimated remaining time as HH:MM:SS.

Definition at line 84 of file timestamp.hpp.

◆ hours_minutes_seconds_from_seconds()

std::string triqs::utility::hours_minutes_seconds_from_seconds ( double sec)
inline

#include <triqs/utility/timestamp.hpp>

Format an absolute number of seconds as HH:MM:SS.

Parameters
secDuration in seconds.
Returns
Zero-padded HH:MM:SS string.

Definition at line 61 of file timestamp.hpp.

◆ stack_trace()

std::string triqs::utility::stack_trace ( )

#include <triqs/utility/stack_trace.cpp>

Capture the current call stack and return it as a demangled, human-readable string.

Returns
The current stack trace, one frame per line.

Definition at line 35 of file stack_trace.cpp.

◆ timestamp()

std::string triqs::utility::timestamp ( )
inline

#include <triqs/utility/timestamp.hpp>

Current local time formatted as HH:MM:SS.

Returns
Local time string.

Definition at line 47 of file timestamp.hpp.