table of contents
QBUTIL.H(3) | libqb Programmer's Manual | QBUTIL.H(3) |
NAME¶
qbutil.h - These are some convience functions used throughout libqb.
SYNOPSIS¶
#include <qb/qbutil.h>
DESCRIPTION¶
Locking
Time functions
Basic Stopwatch
uint64_t elapsed1; uint64_t elapsed2; qb_util_stopwatch_t *sw = qb_util_stopwatch_create(); qb_util_stopwatch_start(sw); usleep(sometime); qb_util_stopwatch_stop(sw); elapsed1 = qb_util_stopwatch_us_elapsed_get(sw); usleep(somemoretime); qb_util_stopwatch_stop(sw); elapsed2 = qb_util_stopwatch_us_elapsed_get(sw); qb_util_stopwatch_free(sw);
Stopwatch with splits
Setup a stopwatch with space for 3 splits.
uint64_t split; qb_util_stopwatch_t *sw = qb_util_stopwatch_create(); qb_util_stopwatch_split_ctl(sw, 3, 0); qb_util_stopwatch_start(sw); usleep(sometime); qb_util_stopwatch_split(sw); usleep(somemoretime); qb_util_stopwatch_split(sw); usleep(somemoretime); qb_util_stopwatch_split(sw); idx = qb_util_stopwatch_split_last(sw); do {
split = qb_util_stopwatch_time_split_get(sw, idx, idx);
qb_log(LOG_INFO, "split %d is %"PRIu64"", last, split);
idx--; } while (split > 0); split = qb_util_stopwatch_time_split_get(sw, 2, 1); qb_log(LOG_INFO, "time between second and third split is %"PRIu64"", split); qb_util_stopwatch_free(sw);
SEE ALSO¶
qb_util_nano_current_get(3), qb_util_stopwatch_stop(3), qb_util_stopwatch_split(3), qb_util_stopwatch_split_ctl(3), qb_thread_unlock(3), qb_strerror_r(3), qb_util_stopwatch_time_split_get(3), qb_util_set_log_function(3), qb_util_timespec_from_epoch_get(3), qb_thread_lock_destroy(3), qb_thread_trylock(3), qb_util_nano_monotonic_hz(3), qb_util_nano_from_epoch_get(3), qb_util_stopwatch_create(3), qb_util_stopwatch_split_last(3), qb_thread_lock(3), qb_util_stopwatch_free(3), qb_thread_lock_create(3), qb_timespec_add_ms(3), qb_util_stopwatch_start(3), qb_util_stopwatch_us_elapsed_get(3), qb_util_stopwatch_sec_elapsed_get(3)
COPYRIGHT¶
Copyright (C) 2010-2020 Red Hat, Inc.
2023-07-21 | LIBQB |