x = x .. "\n", the garbage collector will eventually run and collect this string. When you're concatenating large strings together over and over again (like in a loop) that will add up quickly and force the garbage collector to run and will slow down code by a lot the larger those strings are.
fwill perform faster than
f_2because both functions used are saved in a local variable rather than getting retrieved from
_G, which saves time over a long period of time.