![]() |
Flowgrind
Advanced TCP traffic generator
|
Timing related routines used by Flowgrind. More...
Go to the source code of this file.
Macros | |
#define | NSEC_PER_SEC 1000000000L |
Number of nanoseconds per second. More... | |
Functions | |
const char * | ctimenow (bool ns) |
Returns the current wall-clock time as null-terminated string. More... | |
const char * | ctimenow_r (char *buf, size_t size, bool ns) |
Returns the current wall-clock time as null-terminated string. More... | |
const char * | ctimespec (const struct timespec *tp, bool ns) |
Converts timespec struct tp into a null-terminated string. More... | |
const char * | ctimespec_r (const struct timespec *tp, char *buf, size_t size, bool ns) |
Converts timespec struct tp into a null-terminated string. More... | |
int | gettime (struct timespec *tp) |
Returns the current wall-clock time with nanosecond precision. More... | |
bool | normalize_tp (struct timespec *tp) |
Normalizes timespec struct tp . More... | |
void | time_add (struct timespec *tp, double seconds) |
Add an amount of time seconds to a specific point in time tp . More... | |
double | time_diff (const struct timespec *tp1, const struct timespec *tp2) |
Returns the time difference between two the specific points in time tp1 and tp2 . More... | |
double | time_diff_now (const struct timespec *tp) |
Returns time difference between now and the specific point in time tp . More... | |
bool | time_is_after (const struct timespec *tp1, const struct timespec *tp2) |
Returns true if second point in time tp2 is chronologically after the first point in time tp1 . More... | |
Timing related routines used by Flowgrind.
Definition in file fg_time.h.
#define NSEC_PER_SEC 1000000000L |
const char* ctimenow | ( | bool | ns | ) |
Returns the current wall-clock time as null-terminated string.
The function returns a pointer to static data and hence is not thread-safe. The thread-safe version is ctimenow_r().
[in] | ns | if returned time string should have nanosecond precision |
const char* ctimenow_r | ( | char * | buf, |
size_t | size, | ||
bool | ns | ||
) |
Returns the current wall-clock time as null-terminated string.
It stores the string in a user-supplied buffer buf
.
[out] | buf | buffer with room for at least 30 bytes |
[in] | size | size of the buffer |
[in] | ns | if returned time string should have nanosecond precision |
Definition at line 47 of file fg_time.c.
const char* ctimespec | ( | const struct timespec * | tp, |
bool | ns | ||
) |
Converts timespec struct tp
into a null-terminated string.
The function returns a pointer to static data and hence is not thread-safe. The thread-safe version is ctimespec_r().
[in] | tp | point in time |
[in] | ns | if returned time string should have nanosecond precision |
const char* ctimespec_r | ( | const struct timespec * | tp, |
char * | buf, | ||
size_t | size, | ||
bool | ns | ||
) |
Converts timespec struct tp
into a null-terminated string.
It stores the string in a user-supplied buffer buf
.
[in] | tp | point in time |
[out] | buf | buffer with room for at least 30 bytes |
[in] | size | size of the buffer |
[in] | ns | if returned time string should have nanosecond precision |
Definition at line 66 of file fg_time.c.
int gettime | ( | struct timespec * | tp | ) |
Returns the current wall-clock time with nanosecond precision.
Since the returned time is retrieved from a system-wide clock that measures real time, the time is may be affected by discontinuous jumps in the system time (e.g., if admin manually changes the clock), and by the incremental adjustments performed by NTP.
[out] | tp | current time in seconds and nanoseconds since the Epoch |
Definition at line 145 of file fg_time.c.
bool normalize_tp | ( | struct timespec * | tp | ) |
Normalizes timespec struct tp
.
Ensures that the equation 0 <= tp->tv_nsec < NSEC_PER_SEC holds, meaning that the amount of nanoseconds is not negative less than one second.
[in,out] | tp | point in time |
Definition at line 119 of file fg_time.c.
void time_add | ( | struct timespec * | tp, |
double | seconds | ||
) |
double time_diff | ( | const struct timespec * | tp1, |
const struct timespec * | tp2 | ||
) |
double time_diff_now | ( | const struct timespec * | tp | ) |
bool time_is_after | ( | const struct timespec * | tp1, |
const struct timespec * | tp2 | ||
) |
Returns true if second point in time tp2
is chronologically after the first point in time tp1
.
[in] | tp1 | point in time |
[in] | tp2 | point in time |