Conversation
Fixed point calculation for improved accuracy, dithering in debug builds only. Averaging and optional multiplier can be set as compile flags, example for speed testing with long averaging and a 10x multiplier: -D FPS_CALC_AVG=200 -D FPS_MULTIPLIER=10 The calculation resolution is limited (9.7bit fixed point) so values larger than 200 can hit resolution limit and get stuck before reaching the final value. If WLED_DEBUG is defined, dithering is added to the returned value so sub-frame accuracy is possible in post-processingwithout enabling the multiplier.
|
@DedeHai looks very good for me, thanks. Two questions
|
edit: |
Thanks for your explanations. I think 511 FPS is future-safe for a long time ;-) |
|
just for reference: I use this to check FPS in my tests https://pypi.org/project/wled2graph/ |
| #ifdef WLED_DEBUG | ||
| return (FPS_MULTIPLIER * (_cumulativeFps + (random16() & 63))) >> 7; // + random("0.5") for dithering | ||
| #else | ||
| return (FPS_MULTIPLIER * _cumulativeFps) >> 7; // _cumulativeFps is stored in fixed point 9.7 bit |
There was a problem hiding this comment.
Maybe replace all places with "7" by a constant (#define) ?
Its better for maintainability to leave a hint what the magic number "7" stands for - in this case the fixed point fraction bits.
dithering is not really needed, the FPS_MULTIPLIER is a much better option.
softhack007
left a comment
There was a problem hiding this comment.
Looks good 👍 I approve
Actually the old FPS code was always "broken" in a sense that it stops converging to real FPS when the delta is below 2. So we could see this as a bugfix that would fit into 0.15.
This improvement is for dev purposes mainly but it also gives a bit smoother FPS return values in normal builds.
Changes:
- dithering (in debug builds only)Example for speed testing with long averaging and a 10x multiplier:
Since the calculation resolution is limited (9.7bit fixed point)
FPS_CALC_AVGvalues larger than 200 can hit resolution limit and get stuck before reaching the final value.If
WLED_DEBUGis defined, dithering is added to the returned value so sub-frame accuracy is possible in post-processing without enabling the multiplier.