mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-05-17 18:36:21 +03:00
Fix dividing 0 error in stress/cpp/microbench
Summary: Per issue #2356, some CXX compilers may optimize away the new/delete operation in stress/cpp/microbench.cpp. Thus, this commit (1) bumps the time interval to 1 if it is 0, and (2) modifies the pointers in the microbench to volatile.
This commit is contained in:
parent
e8f9f13811
commit
a74acb57e8
2 changed files with 29 additions and 18 deletions
|
|
@ -28,6 +28,17 @@ timer_ratio(timedelta_t *a, timedelta_t *b, char *buf, size_t buflen) {
|
|||
size_t i = 0;
|
||||
size_t j, n;
|
||||
|
||||
/*
|
||||
* The time difference could be 0 if the two clock readings are
|
||||
* identical, either due to the operations being measured in the middle
|
||||
* took very little time (or even got optimized away), or the clock
|
||||
* readings are bad / very coarse grained clock.
|
||||
* Thus, bump t1 if it is 0 to avoid dividing 0.
|
||||
*/
|
||||
if (t1 == 0) {
|
||||
t1 = 1;
|
||||
}
|
||||
|
||||
/* Whole. */
|
||||
n = malloc_snprintf(&buf[i], buflen-i, "%"FMTu64, t0 / t1);
|
||||
i += n;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue