Earlier quoted context omitted.
I Updated the run bench function https://gist.github.com/mzaks/e3a2dc7ccdfc2397bc26c55eb6dc8a... the output is now: Eager run ================================= 1557 ms encode 264 ms decode 34 ms use 206 ms dealloc 504 ms decode+use+dealloc 0,38 ms direct 0,32 ms using struct ================================= Total counter1 is 8644311667000000 Total counter2 is 8644311667000000 Total counter3 is 8644311667000000 Encod…
The function call is not being optimized out, it's being hoisted outside the loop. I.e., it is as if the code was written as: let result = flatuseStruct(outputData) for _ in 0.. The counter will still be correct, but you are not measuring what you think you are measuring.
Changed the iteration to:
for i in 0..
now result is around 43msThanks for pointing it out. Have to check if there are so other things involved, but that might be it.