There is a huge difference in time consumption between calling a function sentence by sentence and calling the entire function at once

No, I mean, in the test with @btime in the lines did you execute both the line with the @btime and without it? As in the code you posted.