Binary executable slower on the first run

Hi everyone,

I’ve compiled an executable using crystal build script.cr --release and noticing that it is slower the first time I run it. After the first run I get the performance I’m looking for. Is this behavior expected?

First run

real	0m0.661s
user	0m0.159s
sys	0m0.090s

Second run

real	0m0.083s
user	0m0.059s
sys	0m0.027s

I’ve done this rough testing and from the second run, the average time it takes to run is ~0m0.081s. Is this expected?

Is this on a Mac? I think in recent versions they changed something and do some checks when an executable runs the first time. You could check if that’s also true with other languages, like Go, Rust or Nim

Yes, it’s on a Mac. Do you know what checks are being performed and if one can choose to skip them?

Maybe this? Catalina is checking notarization of unsigned executables

2 Likes

Thanks!