|
TEC
A lightweight C++ library enabling safe, efficient execution in multithreaded and concurrent systems.
|
Provides time-related utilities and system information functions for the tec namespace. More...
#include <chrono>#include <cstdio>#include <string>#include "tec/tec_def.hpp"#include <unistd.h>#include <pwd.h>#include <linux/limits.h>Go to the source code of this file.
Classes | |
| class | tec::Timer< Duration > |
| A simple timer for measuring elapsed time. More... | |
Functions | |
System Utilities | |
Functions for retrieving system information (non-Windows platforms). Provides utilities for retrieving the computer name and username on non-Windows platforms. Windows-specific utilities are defined in tec/mswin/tec_win_utils.hpp. | |
| std::string | tec::getcomputername () |
| Retrieves the computer hostname. | |
| std::string | tec::getusername () |
| Retrieves the logged-in username. | |
Time Utilities | |
Type aliases and functions for time-related operations. Provides utilities for measuring time intervals using a monotonic clock, along with type aliases for common time durations and time points. | |
| using | tec::Clock = std::chrono::steady_clock |
| Type alias for a monotonic clock suitable for measuring intervals. | |
| using | tec::Seconds = std::chrono::seconds |
| Type alias for seconds duration. | |
| using | tec::TimePointSec = std::chrono::time_point< Clock, Seconds > |
| Type alias for a time point in seconds. | |
| using | tec::MilliSec = std::chrono::milliseconds |
| Type alias for milliseconds duration. | |
| using | tec::TimePointMs = std::chrono::time_point< Clock, MilliSec > |
| Type alias for a time point in milliseconds. | |
| using | tec::MicroSec = std::chrono::microseconds |
| Type alias for microseconds duration. | |
| using | tec::TimePointMu = std::chrono::time_point< Clock, MicroSec > |
| Type alias for a time point in microseconds. | |
| template<typename Duration > | |
| Duration | tec::now () |
| Returns the current time as a duration since the epoch. | |
| template<typename Duration > | |
| Duration | tec::since (Duration start) |
| Returns the duration since a specified start time. | |
| constexpr const char * | tec::time_unit (Seconds) |
| Returns the unit string for a duration type. | |
| constexpr const char * | tec::time_unit (MilliSec) |
| constexpr const char * | tec::time_unit (MicroSec) |
| constexpr Seconds | tec::one_hour () |
| Returns a constant duration of one hour. | |
| constexpr Seconds | tec::one_day () |
| Returns a constant duration of one day. | |
Provides time-related utilities and system information functions for the tec namespace.
| using tec::Clock = typedef std::chrono::steady_clock |
Type alias for a monotonic clock suitable for measuring intervals.
Uses std::chrono::steady_clock for consistent interval measurements.
|
inline |
Retrieves the computer hostname.
Returns the hostname of the current system using UTF-8 encoding. Returns an empty string on failure.
|
inline |
Retrieves the logged-in username.
Returns the username of the current user using UTF-8 encoding. Returns an empty string on failure.
| Duration tec::now | ( | ) |
Returns the current time as a duration since the epoch.
Measures the time elapsed since the clock's epoch, cast to the specified duration type.
| Duration | The duration type (e.g., Seconds, MilliSec, MicroSec). |
|
constexpr |
Returns a constant duration of one day.
Provides a constant representing one day in seconds.
|
constexpr |
Returns a constant duration of one hour.
Provides a constant representing one hour in seconds.
| Duration tec::since | ( | Duration | start | ) |
Returns the duration since a specified start time.
Calculates the time elapsed since the given start time, using the specified duration type.
| Duration | The duration type (e.g., Seconds, MilliSec, MicroSec). |
| start | The start time as a duration since the epoch. |
|
constexpr |
Returns the unit string for a duration type.
Provides a human-readable string representing the unit of the specified duration type.
| duration | The duration type (e.g., Seconds, MilliSec, MicroSec). |