Блог пользователя pranshukas

Автор pranshukas, история, 4 года назад, По-английски

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 ->

  • Проголосовать: нравится
  • +6
  • Проголосовать: не нравится

»
4 года назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

I suggest using precompiled header.

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится -11 Проголосовать: не нравится

    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.

    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Refer to point 5 on this blog. I have done using this.

      • »
        »
        »
        »
        14 месяцев назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        When I copy paste the path in cmd Its showing this error: 'C:\MinGW\lib\gcc\mingw32\6.3.0\include\c++\mingw32\bits' is not recognized as an internal or external command, operable program or batch file.

        What shall I do now

        • »
          »
          »
          »
          »
          14 месяцев назад, # ^ |
          Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

          You need to find the location of your bits/stdc++.h.

          Create a c++ file which includes that header and open that folder on command line.

          Then run the following command

          g++ -H file_name.cpp
          

          then it will show the location of the header on the first line

»
4 года назад, # |
  Проголосовать: нравится +25 Проголосовать: не нравится

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

When my compilation slowed down disabling anti-virus helped.

»
4 года назад, # |
  Проголосовать: нравится +11 Проголосовать: не нравится

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.

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится -8 Проголосовать: не нравится

    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?

    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится +3 Проголосовать: не нравится

      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.

»
4 года назад, # |
  Проголосовать: нравится -28 Проголосовать: не нравится

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

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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.

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    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 ?

    • »
      »
      »
      4 года назад, # ^ |
      Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится

      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

»
4 года назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

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

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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 года назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

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

»
4 года назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

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>

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +3 Проголосовать: не нравится

    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

»
4 года назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

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

»
18 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

thankuuuu so much... i was too much frustrated bcoz of this f***ing mcafee

»
4 месяца назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

watch this vid https://www.youtube.com/watch?v=WRtpcQJYCZQ and do not forget to select the CP is the build system

»
4 месяца назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

True even now it is taking too much time to compile and also create a confusion state in mind whether my code will give runtime error or it will run; there should be new releases.