Visual studio 2012 slow compile time

假装没事ソ 提交于 2019-12-20 04:04:31

问题


I have an extremely small project in visual studio 2012 (only 50 lines of code). I only have one source file (main.cpp). But yet it takes about 20 seconds or more to compile! How am I supposed to speed it up? When I use C# the compile times are fast but when it comes to C++ it's super slow.

As for my minimal computer specs, I have an i5 processor, 4gb of ram and it is a quad core. It shouldn't be taking this long to compile something that is only 50 lines long. What should I do?

My Code:

    #include<iostream>
using namespace std;

class Entity
{
protected: 
    int health; 
public: 
    void SetHealth(int value)
    {
        health = value;
    }

    void DisplayHealth()
    {
        cout << "Entity: " << health << endl;
    }
};

class Player : public Entity
{
private:
    int xp;
public: 
    void DisplayHealth()
    {
        cout << "Player: " << health << endl;
    }
};

class Enemy : public Entity
{

};

int main()
{
    Player player; 

    Entity *entity = &player;

    entity->SetHealth(10); 
    player.DisplayHealth();

    system("pause");
    return 0;
}

回答1:


The code is not using anything that can make the compiler sweat.

Some options that might hold up performance: clear %localappdata%\Microsoft\WebSiteCache Also clear out %localappdata%\temp folder.

Unplug your n/w cable and try (or turn of wireless connection).

Also in tools\options\debugging: disable edit and continue. you might be generating MAP, PDB etc... See what you need and what you don't.

Some people have reported that turning of "hardware acceleration' helps (options)!

Check your PCH (pre compiled header file) and see if it has grown too big.

Allow incremental linking so that everthing is not being built all the time.

Also, ensure that the disk is not fragmented.



来源:https://stackoverflow.com/questions/13057396/visual-studio-2012-slow-compile-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!