Sublime Forum

Sublime Text takes 6 seconds while executing cout<<"Hello World"<<endl;

#1

Hello Technical Support,
My sublime text editor’s execution becomes very slow. It takes 6 - 20 sec to execute a very basic program like cout<<“Hello World”<<endl; . It shows [Finished in 6.2s]. I have sublime text editor version 3.2.2 and build 3211. It is installed on my Mac having spec 1.8 GHz Dual-Core Intel Core i5 with 128GB SSD and 8 GB Ram.

Please resolve this issue.

0 Likes

#2

Sublime Text itself doesn’t compile and run code directly. Are you using a build system to compile and run your code? Does it also take 6 seconds running the same commands on a terminal?

0 Likes

Unusally High execution time for Cpp codes.10sec for even simple codes like cout<<a+b; I use Windows 10
#3

It is running fine when I open terminal and build it using command “g++ file_name.cpp” and run it by using command “/a.out” .

But when I am building it with “command + B” in sublime text the it takes time.

0 Likes

#4

Can you confirm that you’re using the built-in build system? Have you tried reverting to a freshly installed state?

0 Likes

#5

Yes I am using Built in build system and I also tried reverting to a freshly installed state. But the issue still persists and it will take 3 - 4 seconds for a very simple program to build it.

0 Likes

#6

Sometimes the same program takes more time but sometimes it will take less time also. I generally use input.txt and output.txt file for input and output. The Screenshot of my layout is attached below.

@bschaaf Thanks in advance.

0 Likes

#7

Have you try without the sync_with_stdio line? What’s the result of running time bash -c "g++ Setup.cpp -o Setup && ./Setup" in a terminal?

1 Like

#8

@bschaaf I tried without using sync_with_stdio line and here are the results of terminal.

0 Likes

#9

You need to use the exact command I gave. The command you ran only measures the time it takes to compile, not compile and run.

0 Likes

#10

Sorry for the wrong command. The screenshot is attached with the right command.

@bschaaf

0 Likes

#11

Could you try making a custom build system that uses time in the same way to see if g++ is actually running slower from ST or if ST is measuring the execution time wrong?

0 Likes

#12

@bschaaf Sorry I don’t know how to do that. Can you send me the code for that so that I can run it on my system.

0 Likes

#13

Here’s a modified version of the default C++ Single File.sublime-build that should work:

{
	"shell_cmd": "time bash -c \"g++ ${file} -o ${file_path}/${file_base_name} && ${file_path}/${file_base_name}\"",
	"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
	"working_dir": "${file_path}",
	"selector": "source.c++",
}
0 Likes

#14

@bschaaf Where I have to update this code on my system?

Thanks for the Help.

0 Likes

#15

Hi, just noticed this thread on the mailing list.

https://docs.sublimetext.io/guide/usage/build-systems.html#where-to-store-build-systems

I got to be Packages/User/ under Sublime Text 3 configuration directory. Preferences -> Browse Packages menu should open file manager with the right path. Not so sure about OS X, though.

0 Likes

#16

@ratijas @bschaaf Thanks for the help. The issue is resolved now.

1 Like

#17

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

0 Likes

#18

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

0 Likes

#19

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

0 Likes

#20

Please don’t spam the forum. The link ratijas linked explains that you should save the custom build system under Packages/User/. Depending on the OS you’re using you’ll find the Packages folder will be under a different path, as described here: https://www.sublimetext.com/docs/3/revert.html.

0 Likes