代码之家  ›  专栏  ›  技术社区  ›  Didier Trosset

如何提高Visual C++的编译时间?

  •  47
  • Didier Trosset  · 技术社区  · 16 年前

    我在BudidBOT中编译2个C++项目,每个提交。这两个都是大约1000个文件,一个是100 kloc,另一个是170 kloc。编译时间与GCC(4.4)到Visual C++(2008)有很大的不同。

    一个项目的Visual C++编译在20分钟内完成。它们不能利用多个核心,因为一个项目依赖于另一个。最后,用32位和64位对调试和发布中的两个项目进行完整编译需要2 1/2小时以上。

    一个项目的GCC编译需要4分钟。它可以在4个内核上并行,大约需要1分10秒。两个项目中的4个版本(调试/发布,32/64位)的所有8个版本都在10分钟内编译完成。

    VisualC++编译时发生了什么?它们基本上慢了5倍。

    编译C++ KLC的平均时间是多少?我的矿山为7 s/kloc(含VC++)和1.4 s/kloc(含GCC)。

    在Visual C++中可以加快编译时间吗?

    12 回复  |  直到 14 年前
        1
  •  16
  •   user180326    14 年前

    const std::string

        5
  •  3
  •   Hollance    16 年前

        6
  •  2
  •   chrish.    16 年前
        7
  •  1
  •   sharptooth    16 年前

        8
  •  1
  •   Thomas Matthews    16 年前

        9
  •  0
  •   e8johan    16 年前

        10
  •  0
  •   Matthieu M.    16 年前

        11
  •  0
  •   AareP    16 年前

    Dim WithEvents myTimer As Timers.Timer
    
    Sub CompileAndLinkCurrentCppFile()
        DTE.ExecuteCommand("Build.Compile")
        myTimer = New Timers.Timer
        myTimer.Interval = 0.05
        myTimer.Start()
    End Sub
    
    Sub myTimer_Elapsed(ByVal ee As Object, ByVal dd As Timers.ElapsedEventArgs) Handles myTimer.Elapsed
        If DTE.Solution.SolutionBuild.BuildState <> vsBuildState.vsBuildStateInProgress And DTE.Solution.SolutionBuild.LastBuildInfo <> 1 Then
            myTimer.Stop()
            DTE.ExecuteCommand("Build.Link")
        End If
    End Sub
    
        12
  •  0
  •   ZXX    15 年前