CMake 性能差异:--build --preset 与 --build dir

问题描述 投票:0回答:1

我有一个包含约 1.5K C/C++ 项目/子目录的 CMake 解决方案,并且我想使用 CMake 预设。这是我的 CMakePresets.json:

{
    "version": 3,
    "cmakeMinimumRequired": {
        "major": 3,
        "minor": 20,
        "patch": 1
    },
    "configurePresets": [
        {
            "name"          : "base"                                ,
            "displayName"   : "Base Config Preset"                  ,
            "description"   : "Base config using VS2019"            ,
            "generator"     : "Visual Studio 16 2019"               ,
            "architecture"  : {"value":"Win32", "strategy":"set"}   ,
            "binaryDir"     : "G:/.bld"                             ,
            "installDir"    : "G:/.dst"
        }
    ],
    "buildPresets": [
        {
            "name"              : "base"                                            ,
            "displayName"       : "Base Build Preset"                               ,
            "description"       : "base build preset"                               ,
            "jobs"              : 0                                                 ,
            "cleanFirst"        : true                                              ,
            "verbose"           : false                                             ,
            "configurePreset"   : "base"
        }
    ]
  }

我观察到以下两种方法之间存在显着的持续时间差异(~40%)(两者都在相同的干净环境中运行):

  1. 使用经典文件夹语法来构建
cmake --preset=base
cmake --build G:\.bld -j
  1. 使用新的预设语法来构建
cmake --preset=base
cmake --build --preset=base -j

两者在 CMake 配置和生成步骤中执行类似。在显示 Microsoft 标头后,在构建步骤期间会出现差异:

Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

方法 1. 在显示以下输出行之前没有任何延迟。总时间约为14分钟

方法 2. 在显示输出的下一行之前有 5-6 分钟的延迟(但 CPU 处于负载状态)。再次显示 Microsoft 的标题,然后一切正常。总时间约20分钟

持续时间差异似乎或多或少是在没有显示任何内容时的初始延迟

它们不应该是相同的吗? 可能是 CMake 中的错误或者我做错了什么?

操作系统:Windows 10 64位,cmake版本3.21.2

performance cmake build preset
1个回答
0
投票

这是由于在构建预设中包含了

cleanFirst": true
,这导致
--cleanFirst
被传递用于构建。

© www.soinside.com 2019 - 2024. All rights reserved.