Commit 53c9c964 authored by Dmitry Panin's avatar Dmitry Panin Committed by Pavlo Kushnir

Fix integer overflow in folly/Benchmark.cpp

Summary:
`bm_max_secs` has type int32
So when this value is more than 2, expression
```
FLAGS_bm_max_secs * 1000000000;
```
overflows

Test Plan:
I did put a
```
LOG(INFO) << timeBudgetInNs;
```
and observed correct values (before fix they were overflowed)

Reviewed By: antonl@fb.com

Subscribers: njormrod, folly-diffs@

FB internal diff: D1663247

Signature: t1:1663247:1415261814:c9154ffde183b2a4f5403e534e47e52e8276c61b
parent 3c1306e1
...@@ -222,7 +222,7 @@ static double runBenchmarkGetNSPerIteration(const BenchmarkFun& fun, ...@@ -222,7 +222,7 @@ static double runBenchmarkGetNSPerIteration(const BenchmarkFun& fun,
static const unsigned int epochs = 1000; static const unsigned int epochs = 1000;
// We establish a total time budget as we don't want a measurement // We establish a total time budget as we don't want a measurement
// to take too long. This will curtail the number of actual epochs. // to take too long. This will curtail the number of actual epochs.
const uint64_t timeBudgetInNs = FLAGS_bm_max_secs * 1000000000; const uint64_t timeBudgetInNs = FLAGS_bm_max_secs * 1000000000ULL;
timespec global; timespec global;
CHECK_EQ(0, clock_gettime(CLOCK_REALTIME, &global)); CHECK_EQ(0, clock_gettime(CLOCK_REALTIME, &global));
......
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