c++performancevisual-studio-codecompiled

VSCode compiles slower C++ even though I'm using the same command line script


C++ code compiled from a command line shell script runs much faster than when I use the same shell script from a Task:Run in VSCode. I successfully tried an echo command in the script to make sure VSCode was running the same script I use at the command line.

I know there are compiler settings in a .json file, but I don't see how to add a -O3 optimization switch, and since VSCode is running the same script I used at the command line I just don't get why it might be different. I'm on a new M1 Mac and here's my script: clang++ -std=c++17 -O3 -o $1 $1.cpp && $1

The VSCode resulting speed is midway between the -O3 option and no optimization. Weird.... At first I thought it might be the terminal in VSCode but the code runs same slowness if I execute it at the external command line, so that's not it.


Solution

  • I found the answer. Turns out it's because VSC isn't Apple Silicon native yet and I'm on an M1 Mac. Anything I did from inside VSC, even the terminal window, forced the results to be x86_64 code, which runs 4x slower than the arm64 code I compile from outside VSC. Need to wait for the native version I guess.