first execution of executable has a delay

Viewed 67

I'm on macOS. whenever I compile a program (c++ or swift) and run it for the first time it takes a delay. then the subsequent runs don't take that delay. for example:

miglanigursimar@Miglanis-MacBook-Pro cc % cat main.cc
int main() {}
miglanigursimar@Miglanis-MacBook-Pro cc % g++ main.cc
miglanigursimar@Miglanis-MacBook-Pro cc % time ./a.out
./a.out  0.00s user 0.00s system 1% cpu 0.440 total
miglanigursimar@Miglanis-MacBook-Pro cc % time ./a.out
./a.out  0.00s user 0.00s system 59% cpu 0.003 total

why? any way to not have this delay??

0 Answers
Related