Unverified Commit 99ebbee2 authored by Ozan Tezcan's avatar Ozan Tezcan Committed by GitHub
Browse files

Fix overflow in redis-benchmark (#11102)

Fix overflow in redis-benchmark affecting latency measurements on 32bit builds.

If `long` is 4 bytes (typical on 32 bit systems), multiplication overflows.
Using `long long` will fix the issue as it is guaranteed to be at least 8 bytes. 

Also, I've added a change to reuse `ustime()` for `mstime()`. 
parent 44859a41
...@@ -229,19 +229,13 @@ static long long ustime(void) { ...@@ -229,19 +229,13 @@ static long long ustime(void) {
long long ust; long long ust;
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
ust = ((long)tv.tv_sec)*1000000; ust = ((long long)tv.tv_sec)*1000000;
ust += tv.tv_usec; ust += tv.tv_usec;
return ust; return ust;
} }
static long long mstime(void) { static long long mstime(void) {
struct timeval tv; return ustime()/1000;
long long mst;
gettimeofday(&tv, NULL);
mst = ((long long)tv.tv_sec)*1000;
mst += tv.tv_usec/1000;
return mst;
} }
static uint64_t dictSdsHash(const void *key) { static uint64_t dictSdsHash(const void *key) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment