mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-24 17:47:22 +03:00
Add nstime_ns_since which obtains the duration since the input time.
This commit is contained in:
parent
cafe9a3158
commit
310af725b0
3 changed files with 42 additions and 0 deletions
13
src/nstime.c
13
src/nstime.c
|
|
@ -158,6 +158,19 @@ nstime_divide(const nstime_t *time, const nstime_t *divisor) {
|
|||
return time->ns / divisor->ns;
|
||||
}
|
||||
|
||||
/* Returns time since *past, w/o updating *past. */
|
||||
uint64_t
|
||||
nstime_ns_since(const nstime_t *past) {
|
||||
nstime_assert_initialized(past);
|
||||
|
||||
nstime_t now;
|
||||
nstime_copy(&now, past);
|
||||
nstime_update(&now);
|
||||
|
||||
assert(nstime_compare(&now, past) >= 0);
|
||||
return now.ns - past->ns;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
# define NSTIME_MONOTONIC true
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue