pranshukas's blog

By pranshukas, history, 10 months ago, In English

I am using Sublime Text Editor for Writing C++ Programs but it's taking too much time to Compile even small Programs. Even printing Hello World takes 4-5s.

I have been using Windows 10, My PC Configuration is — i7 9750H, 16GB Ram, and 512GB SSD. I am still wondering why is it still slow. I have seen many Competitive Programmers during screencasting videos using Sublime text and their Compile Time is merely 0.8-1.2s. But mine is taking too much time which cost me patience and time During Contests.

One thing that I have seen is those Competitive Programmers were using macOS or Linux. I was wondering if Sublime Text really slow on Windows or I have done some mistakes while installing it.

I have tried Googling my Problem but unable to find any solution, I had asked this Question on Stackoverflow also but there also I didn't get any reply.

Please Someone Help me fixing it or comment on some related article that I can read to fix it.

Below is ScreenShot even this small Program took 15.3s ->

 
 
 
 
  • Vote: I like it
  • +6
  • Vote: I do not like it

»
10 months ago, # |
  Vote: I like it +5 Vote: I do not like it

I suggest using precompiled header.

  • »
    »
    10 months ago, # ^ |
      Vote: I like it -11 Vote: I do not like it

    I tried making my Precompiled Header Files and it's running fine on my local system but when I am trying to submit it on online judges it's showing no such files found.

    How can I make a precompiled file that would be automatically attached while submitting solutions on Online Judge.

»
10 months ago, # |
  Vote: I like it +25 Vote: I do not like it

Try disabling your anti-virus if you have any 3rd party anti-virus.

When my compilation slowed down disabling anti-virus helped.

»
10 months ago, # |
  Vote: I like it +11 Vote: I do not like it

I have used sublime text both on windows and ubuntu , and it does seem that sublime works faster on linux systems. Still, it is weird. More than 15 seconds to run the program , it is just crazy. On ubuntu, it takes about 0.5 to 1.5 seconds in general, if I have precompiled headers. For windows, it takes about 3-5 seconds, even with precompiled headers. Still, I have seen people run sublime quite smoothly on windows, so yeah it is weird.Sublime behaves differently on different systems, and on different machines too, which sucks bad.

  • »
    »
    10 months ago, # ^ |
      Vote: I like it -8 Vote: I do not like it

    The Same Thing happens to me. But generally, the compilation is more than 5-10s. Have You Created Your own build System or Sublime Text c++11 one?

    • »
      »
      »
      10 months ago, # ^ |
        Vote: I like it +3 Vote: I do not like it

      I am using the sublime text c++ 11 one. I think that the custom build is slightly slower, but again, some other people might have seen different results.

»
10 months ago, # |
  Vote: I like it -28 Vote: I do not like it

Try "bits/stdc++.h" instead of <bits/stdc++.h>

»
10 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Earlier I used to get speed of 0.8 -1.5 sec. Now after reinstalling all it takes first compilation to 15-20 secs..After that it return to normal speed of 1-2sec..I also used precompiler headers but no effect

»
10 months ago, # |
  Vote: I like it 0 Vote: I do not like it

As someone already mentioned, it is a common issue with third-party antivirus. Try excluding those folders from antivirus where your .exe files get created.
Immediate solution would be to switch to an online IDE.

ps: If you have McAfee antivirus, there is no solution but either uninstall it or deactivate there Realtime scanning whenever you compile your code because they don't provide folder exclusion option.

  • »
    »
    10 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Yeah, I have McAfee Antivirus installed, will uninstalling it and switching to Windows defender will solve the Problem? Or will I need to turn of Windows Defender too?

    One more thing Can just turning off Real-Time Scanning in McAfee will solve the issue ?

    • »
      »
      »
      10 months ago, # ^ |
      Rev. 2   Vote: I like it +3 Vote: I do not like it

      Try to do compilation after uninstalling McAfee and if it works out, then uninstall it forever. My personal opinion, McAfee is shit and it slows down your system more than it protects it. If you are a casual user (not much into the deep web and torrents), then Windows defender will get the job done. Just never install untrusted applications and you should be good to go

    • »
      »
      »
      10 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      First, check whether the issue is with your anti-virus or not, to do that you don't need to uninstall McAfee, just turn off their real-time protection and check compilation time.

      If it works, then I would suggest uninstalling McAfee and switching to Windows Defender rather than turning off just McAfee Real-time protection forever (Though u can also turn off it for a limited time whenever you compile but that what be very tedious to do every time), because latter will leave your PC prone to virus, since neither McAfee nor Windows defender will be doing real-time protection.

      If the problem persists even with Windows Defender, Windows Defender provide the feature to exclude Folder. Just do what I told in the first reply and you will be good to go.

      And yeah McAfee really sucks for this issue :'(

»
10 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Just write around 8-10 most frequently used header files instead of writing <bits/stdc++.h>. This greatly decreased my compile time.

»
10 months ago, # |
  Vote: I like it 0 Vote: I do not like it

In my laptop, there is a pre-installed app that could switch my laptop between performance/battery mode (not the one from Windows Settings/Control Panel). Compiling a hello world program (with bits/stdc++.h precompiled) takes 0.3-0.5s on performance mode and 1.2-1.4s on battery mode. Turning off Windows Defender reduces the compilation time by ~0.1s in my case.

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Can you tell me the name of the app, please? Is it the one which comes with HP laptops?

»
10 months ago, # |
  Vote: I like it +3 Vote: I do not like it

Install WSL, and make your build system run commands on WSL terminal, rather than CMD.

  • »
    »
    10 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Does this shorten compilation time?

»
10 months ago, # |
Rev. 2   Vote: I like it -8 Vote: I do not like it

it usually happens to me when my laptop isnt plugged in. i also have the same specs. also, when i am not using freopen it compiles faster. edit: the reason I am talking about the laptop is because OP said he has '9750H' which is a laptop processor and when the laptop isn't plugged in it's in power-saving mode. currently, I am not using freopen and it compiles way faster for me

»
10 months ago, # |
  Vote: I like it 0 Vote: I do not like it
  • »
    »
    10 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I have installed Fast Olympic Coding Plugin through package install but after installing it Sublime Text is behaving abnormally. It stops responding and I have to close and restart it again.

»
10 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Earlier I had the same issue. It took around 15-17 seconds. After disabling my antivirus it came down to 1.5-2 second.Use precompiled headers or stop using <bits/stdc++.h>

  • »
    »
    10 months ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    I am not able to understand what does it mean by Precompiled Header File. I made a header file temp.h and included in my program #include "temp.h" but when I submitted it on online judge it's giving Compilation Error. No Such files found. But it's running on my local system.

    Can You Please Help me out. How to create Precompiled Header Files which would work on online judges as well. Please tell me or attach any tutorial or video so that I can learn.

    I tried Googling up end up getting confused. Even I am asking people here in the community but I don't know why people are insanely just downvoting me instead of helping.

    Hope You Help !! Thanks

»
9 months ago, # |
  Vote: I like it +3 Vote: I do not like it

Also, turn off O2 optimization will also reduce compilation time if you're not stress testing.

»
9 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Since you use sublime you might want to try out CppFastOlympicCoding package. It's pretty sleek and I use it too.

https://packagecontrol.io/packages/CppFastOlympicCoding

»
4 weeks ago, # |
  Vote: I like it -12 Vote: I do not like it

switch to another IDE.

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Have u made any changes in settings? Because it works fine for me without any changes

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    If you don't mind I would say you to change your profile picture. It is dangerous for me.

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Which settings are you referring to?

    As People suggested to uninstall McAfee Antivirus and keep .cpp files in the shred folder, I did that and it greatly improved the speed. If you are referring to any other settings Please tell!

    • »
      »
      »
      4 weeks ago, # ^ |
      Rev. 3   Vote: I like it 0 Vote: I do not like it

      I am taking about these files

      Spoiler

      These are the original settings, and it works fast for me and myself also use antivirus, but it did not affected the speed of execution.