in reply to sprintf vs. substr (for zero-padded values)

Note that a more accurate benchmark of one and two above would test numbers of all lengths, not just three digits. One method may be faster or slower for shorter or longer numbers.

I'm inclined to agree that the speed difference would most likely be small enough that it wouldn't be the primary deciding factor for me in this case. I prefer the sprintf method for ease of implementation and maintenance. If you add in the cost of calling an encapsulated zero-padder instead of printf, your times may be even closer.