An Elegant Problem for You - Why HW Takes So Long to Run on WSL if Using VS Code

When VS Code (I wasn't able to set the gcc that I have in the WSL terminal to be "the" compiler, though, following Goog's advice, I did go to command palette and say wsl-remote new window..

This is what I see (I can't find the exact compile command) the VS Code terminal when I "Run without Debugging"

& 'c:\Users\anant\.vscode\extensions\ms-vscode.cpptools-1.23.2-win32-x64\debugAdapters\bin\WindowsDebugLauncher.exe' '--stdin=Microsoft-MIEngine-In-iet5cxoy.sqy' '--stdout=Microsoft-MIEngine-Out-vq0tqhub.lns' '--stderr=Microsoft-MIEngine-Error-xyos54mn.10t' '--pid=Microsoft-MIEngine-Pid-3ateclpj.3ff' '--dbgExe=C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\gdb.exe' '--interpreter=mi'

VS Code compiled output for a prog that prints a simple message, scanf's an int and prints out that minus 1 : 246 bytes --> 55.03k

gcc : 16k

But, if you run the ./hello.exe, it takes 5 seconds before it does anything, whereas the gcc one takes off right away.

Who can explain all of this?

chatGPT knows, but doesn't know how to get me to know. It did tell me how to hack the tasks.json and launch.json and how to launch VS Code (I knew this ages ago) from WSL.

analog@DESKTOP-O264A5N cou_C $ size hello.exe
   text    data     bss     dec     hex filename
   9852    2284    2432   14568    38e8 hello.exe
analog@DESKTOP-O264A5N cou_C $ size hello
   text    data     bss     dec     hex filename
   1873     624       8    2505     9c9 hello

Does that tell you something? Debug flags included maybe?

#include <stdio.h>

int main() {
    printf("Hello, World!\n");
    printf("Enter US floor: ");
    int us_floor;
    scanf("%d", &us_floor);
    int eu_floor = us_floor - 1;
    printf("European floor: %d\n", eu_floor);
    return 0;
}

Comments

Popular posts from this blog

Poor Documentation - How Could You Do this to Us K&R?

A Classic C Programming Mistake - See if You Can Spot it