05-04-2015 10:52 PM - edited 05-04-2015 11:05 PM
@Oligarlicky wrote:
I'm noticing some weird stuff depending on how I benchmark. If I stick it all in a for loop I can hit ~2 ns/ itteration. To be fair, I'm only doing 256 palindrome checks in my search (everything else gets filtered out).
Watch out for folding artifacts. Hard to tell without seing the code?
Try to caclulate how many clock cycles it takes per iteration. 😄 (e.g. 2ns on a 4GHz prcessor is only 8 clock cycles)
05-05-2015 05:51 AM - edited 05-05-2015 05:54 AM
@Oligarlicky wrote:
[...] all 6 digit palindromes are multiples of 11 [...]
That got me down to 0.3 mS. Thanks.
@Oligarlicky wrote:
I'm noticing some weird stuff depending on how I benchmark. If I stick it all in a for loop I can hit ~2 ns/ itteration. To be fair, I'm only doing 256 palindrome checks in my search (everything else gets filtered out).
I checked 1,388. 😄
05-05-2015 02:55 PM
altenbach wrote: OK, if I include that test, mine drops to 0.12ms (Still using string compare, though) 😄
No longer doing the "11" check, but average time after some optimization is now 0.035ms (35us).
05-14-2015 12:28 PM
Thanks so much!
05-14-2015 12:34 PM
Let us know when the assignment is over so we can compare our versions. Maybe we can all learn something... 😄
Often combining the various "tricks" by the top performers allows the design of new code that is faster than all of them.
05-14-2015 12:40 PM
It was over last Thurseday. I actually tried my best to understand your codes and other top performers' ones by asking my TA and instructors for Labview workshop on campus. Hopefully, I can progress a lot faster with you guys' help.
05-14-2015 12:58 PM - edited 05-14-2015 01:41 PM
For various reasons I love "code miniatures", code that achieves the goal with the smallest amount of code.
For example, my ~35µs code only contains the following elements (+ controls/indicators, the benchmark skeleton, and a few diagram constants that are not shown ;)).
Can you do it? Can you do it with less?
The code needs to solve the problem from first principles (i.e. you cannot just use an indicator wired to a diagram constant of the solution 🐵
(Note that no additional copies of these 13 functions can be added. e.g. you must use exactly two subtraction functions (or less if you dare!))
05-14-2015 02:29 PM
One while loop? Madness
Square? That's gotta be reducing the search space somehow
Also, I couldn't use the min max because I needed the boolean for my case structure.
Surely constant folding is allowed. It's not my fault the compiler is so aggresive 😉
05-14-2015 02:41 PM - edited 05-14-2015 02:43 PM
@Oligarlicky wrote:
Surely constant folding is allowed. It's not my fault the compiler is so aggresive 😉
My code does not do constant folding. e.g. if I replace any of the diagram constant wired to the outer loop with a control, the speed is about the same.
In any case, we could continue the technical discussion in this new, more recreational thread instead. 😄