mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-23 09:07:18 +03:00
Add nstime_ms_since to get time since in ms
Milliseconds are used a lot in hpa, so it is convenient to have `nstime_ms_since` function instead of dividing to `MILLION` constantly. For consistency renamed `nstime_msec` to `nstime_ms` as `ms` abbreviation is used much more commonly across codebase than `msec`. ``` $ grep -Rn '_msec' include src | wc -l 2 $ grep -RPn '_ms( |,|:)' include src | wc -l 72 ``` Function `nstime_msec` wasn't used anywhere in the code yet.
This commit is contained in:
parent
2a693b83d2
commit
b9758afff0
4 changed files with 30 additions and 4 deletions
|
|
@ -228,6 +228,24 @@ TEST_BEGIN(test_nstime_ns_since) {
|
|||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_nstime_ms_since) {
|
||||
nstime_t delta;
|
||||
|
||||
nstime_init2(&delta, /* sec */ 1, /* nsec */ 0);
|
||||
for (uint64_t i = 0; i < 10000; i++) {
|
||||
nstime_t now;
|
||||
nstime_init_update(&now);
|
||||
|
||||
nstime_t past;
|
||||
nstime_copy(&past, &now);
|
||||
nstime_subtract(&past, &delta);
|
||||
|
||||
expect_u64_ge(nstime_ms_since(&past), nstime_ms(&delta),
|
||||
"Incorrect time since result");
|
||||
}
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_nstime_monotonic) {
|
||||
nstime_monotonic();
|
||||
}
|
||||
|
|
@ -248,5 +266,6 @@ main(void) {
|
|||
test_nstime_idivide,
|
||||
test_nstime_divide,
|
||||
test_nstime_ns_since,
|
||||
test_nstime_ms_since,
|
||||
test_nstime_monotonic);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue