Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • How would I check which answer/solution gives the faster result? I always print delta-micros() but is there a better way? Commented Aug 23, 2016 at 10:28
  • The above solution is slow. This is a fast hack to show that you do not need all the libraries mentioned in your original question. See @EdgarBonet's answer for a solution that runs much faster. It can be improved with table lookup to avoid division/modulo. That is what the Cosa version does. Commented Aug 23, 2016 at 10:46
  • Thank you very much. But how you know if this one or the other one is faster? How to determine it? Commented Aug 23, 2016 at 11:01
  • Estimate the algorithms complexity and behavior. Read the generated assembly code and calculate the number of clock cycles. Write a test program and verify. Commented Aug 23, 2016 at 12:34