2 ms·
Well kudos to you for having the right theory! I would have never assumed this behavior on modern CPUs. That trick might still be useful in the embedded space
by pantalaimon 7y ago
Well kudos to you for having the right theory! I would have never assumed this behavior on modern CPUs.
That trick might still be useful in the embedded space - I had to try it on my samr21-xpro too (with only an 8kiB array and slightly modified code - http://codepad.org/aPOZraI2 http://codepad.org/aPOZraI2)
samr21 (Cortex M0+)
naive search
found: 0, took 1714 ticks
found: 0, took 1713 ticks
found: 0, took 1714 ticks
found: 0, took 1714 ticks
found: 0, took 1714 ticks
found: 0, took 1713 ticks
found: 0, took 1714 ticks
found: 0, took 1713 ticks
found: 0, took 1714 ticks
found: 0, took 1714 ticks
average: 1713 ticks
knuth search
found: 0, took 1372 ticks
found: 0, took 1372 ticks
found: 0, took 1372 ticks
found: 0, took 1372 ticks
found: 0, took 1372 ticks
found: 0, took 1372 ticks
found: 0, took 1372 ticks
found: 0, took 1372 ticks
found: 0, took 1372 ticks
found: 0, took 1372 ticks
average: 1372 ticks