DigitalInBlue / Celero

C++ Benchmark Authoring Library/Framework
Other
821 stars 96 forks source link

REQ: Runtime warning if CPU scaling is enabled #111

Open darlingm opened 6 years ago

darlingm commented 6 years ago

I tried out Celero for the first time, and got very inconsistent results.

Tried out google benchmark, and it showed:

***WARNING*** CPU scaling is enabled, the benchmark real time measurements may be noisy and will incur extra overhead.

Would be nice if Celero had a similar warning. I'm betting turning scaling off will fix the inconsistencies I was seeing.

I disabled CPU scaling (well, technically set it to always run at max frequency) by running sudo cpupower frequency-set -g performance. I'll be back to trying Celero soon.

DigitalInBlue commented 6 years ago

When Celero runs, it calls "celero::DisableDynamicCPUScaling()". On Windows, this disables scaling. There is not, however, a linux implementation in the code at this point. This should be added. It seems (to me) better to just turn it off, then to warn that it is on.

darlingm commented 6 years ago

I'm torn on that. I'd be more OK with it as long as on Windows and linux that it puts it back to the setting it started on. But, if for any reason the celero executable crashed or the user stops it (infinite loop perhaps) it would never get set back. Wouldn't be a huge deal for me, but some more worried about energy savings possibly to having many more systems running might feel otherwise.

I believe though that root privileges are required to change it on linux. I think that's why google benchmark just gives the warning.

DigitalInBlue commented 6 years ago

After consideration, I am going to remove automatically setting this on Windows. (It was never implemented for Linux.) A cross-platform warning does seem more appropriate.