When the compiler reaches the code for your for-loop, it replaces the function call absdiff(x0, x1) with the code inside of the function. The while-loop code, on the other hand, introduces some overhead because the program has to create a public activation record (PAR) for the function call, add it to the runtime stack, execute the function, return the values, and finally remove the public activation record (PAR) from the stack. Because of the added functionality that occurs when you run the while-loop, the resulting function calls take longer to execute.