This is because, by default escripts are interpreted, not compiled. It’s significantly slower (especially here where you call a function 250M times), but for the most of the cases it doesn’t matter. If you want escripts to be compiled, you can set -mode(compile) in the escript or pass -c option tho the escript call in shebang: #!/usr/bin/env -S "escript -c"
By default, the script will be interpreted. You can force it to be compiled by including the following line somewhere in the script file:
-mode(compile).
Execution of interpreted code is slower than compiled code. If much of the execution takes place in interpreted code, it can be worthwhile to compile it, although the compilation itself takes a little while.