Skip to content
This repository has been archived by the owner on Sep 20, 2022. It is now read-only.

spectrum-scanner: Run time performance improvements #52

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jnohlgard
Copy link
Member

Experiments show that using ldexpf, ilogbf yields significantly faster
run time performance on Cortex-M0+ without floating point hardware.

@jnohlgard
Copy link
Member Author

This change does truncate the averaged ED to integers, but I don't think the precision matters here because radio noise is not exact, we are only interested in seeing which channels are occupied.

Copy link
Member

@smlng smlng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good code-wise, but also the output changed considerably: i.e. the values are more wide-spread. On master its mostly blue-ish but with this PR it get yellow and green, too. Which I think is good because it makes differences more visible.

Btw. I tested with samr21-xpro, everything still works - with these IMHO good visual enhancements.

Copy link
Member Author

@jnohlgard jnohlgard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why the output changes on samr21-xpro. My intuition tells me that it is because of the increased effective duty cycle of the CCA checks detecting more short frame wifi traffic than before, and thus the average ED level will go up.

@@ -125,10 +126,10 @@ void spectrum_scanner(unsigned long interval_us)
print("] ", 2);
for (unsigned int ch = IEEE802154_CHANNEL_MIN; ch <= IEEE802154_CHANNEL_MAX; ++ch) {
/* Compute the average pseudo-energy and convert back to dB */
ed_average[k][ch] = logf(ed_average[k][ch] / count) * 128.f;
uint32_t ed = ilogbf(ed_average[k][ch] / count);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be int32_t

Experiments show that using ldexpf, ilogbf yields significantly faster
run time performance on Cortex-M0+ without floating point hardware.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants