简体   繁体   English

简单 C++“Hello World”程序的执行时间长

[英]Long execution time on simple C++ 'Hello World' program

A basic (and maybe stupid) question:一个基本的(也许是愚蠢的)问题:

I just started learning C++ and as every first step in a new programming language I wrote a program to print out "Hello World":我刚开始学习 C++,作为新编程语言的每一步,我都编写了一个程序来打印“Hello World”:

#include <iostream>

using namespace std;

int main() 
{
    cout << "Hello World!\n";
    return 0;
}

For this I use the g++ compiler and the compilation finished quickly.为此,我使用了g++编译器,编译很快就完成了。 However the execution time is very long (about 26 seconds according to my IDE).但是执行时间很长(根据我的 IDE 大约为 26 秒)。

Compile command I used (if it should be relevant): g++ main.cpp -o main我使用的编译命令(如果它应该相关): g++ main.cpp -o main

I looked up another guy executing the exact same code with (as far as I know) the exactly same conditions and it took him about 0.05 seconds (according to the output print of his IDE).我查找了另一个执行完全相同代码的人(据我所知)完全相同的条件,他花了大约 0.05 秒(根据他的 IDE 的输出打印)。

I'm pretty sure that something similar to this was already asked a lot of times but I couldn't find any useful information regarding this in about 2 hours of research (maybe looked at the wrong places?) so I think it's justified to ask.我很确定类似的问题已经被问过很多次了,但是在大约 2 个小时的研究中我找不到任何有用的信息(也许看错了地方?)所以我认为这是有道理的.

Any information, an optimization or just some suggestions on where to search, is appreciated.任何信息、优化或只是关于搜索位置的一些建议,我们都表示赞赏。

-VoroX -VoroX

So apparently the antivirus really was the problem, even thou I whitelisted my program, anyway if anyone else has a similar issue, and whilelisting won't help, try to disable your antivirus temporarily.很明显,防病毒确实是问题所在,即使我将我的程序列入白名单,无论如何,如果其他人有类似的问题,虽然列出无济于事,请尝试暂时禁用您的防病毒。

Thanks to Alan Birtles :)感谢 Alan Birtles :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM