Quick test with sprintf. Seems to be 0.1 sec slower than my naive loop.
Testing karma. Seems fast!