Sublime text taking 5-6s to compile and run with pre-compiled headers

I am using sublime text 3 with pre compiled headers as mentioned in this blog.

The build that I am using is as follows :

{
"cmd" : ["g++ -std=c++17 $file_name -o $file_base_name && timeout 4s ./$file_base_name <input.txt >stdout.txt 2>stderr.txt"], 
"selector" : "source.c",
"shell": true,
"working_dir" : "$file_path"
}

If I use <bits/stdc++.h>, it takes 1.2s to compile and run every time I run it using Ctrl+B.

When I use “bits/stdc++.h” (and expect the compilation time to become less) it actually takes 5-6 s to compile and run even the “Hello World” program for the first time using Ctrl+B. From next time, it takes 0.3 s only but the first time, it takes as long as 5-6s.

For every new program that I write, it happens like this. For eg. If I change the “Hello World” program to print 10 numbers from 1-10, it will again take 5-6s to compile and run. Then from the second time, it will take 0.3-0.4 s.

The directory structure is as follows :

CP/

  • bits/
    - stdc++.h
    - stdc++.h.gch
  • code.cpp (this is the file in which I write the code)

I have tried finding some information online but couldn’t find anything useful. Can someone please help me out?

1 Like