Skip to content

Commit 28417e5

Browse files
authored
Merge pull request #6015 from MicrosoftDocs/FromPublicMasterBranch
Confirm merge from FromPublicMasterBranch to main to sync with https://github.com/MicrosoftDocs/cpp-docs (branch main)
2 parents ec731cb + 21903da commit 28417e5

File tree

2 files changed

+41
-40
lines changed

2 files changed

+41
-40
lines changed

docs/build-insights/tutorials/build-insights-template-view.md

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The **Templates** view works like the Build Insights [Functions view](build-insi
2121
1. Select **Modify** to change your Visual Studio installation.
2222
1. On the **Individual components** tab, search for and select **C++ Build Insights**, then select **Close** to finish installing the component.
2323
:::image type="content" source="./media/installer-build-insights.png" alt-text="Screenshot of the Visual Studio Installer. The search box contains C++ Build Insights. The item C++ Build Insights is visible and selected.":::
24-
24+
2525
## Overview
2626

2727
Build Insights, integrated into Visual Studio, helps you optimize your build times--especially for large projects like AAA games. Build Insights provides analytics such as the **Templates** view, which shows the time it takes to instantiate each template and which template instantiations add the most to your build time.
@@ -36,55 +36,56 @@ In this article, you create a project that shows how template instantiation affe
3636
1. Create a header file named `Templates.h`, then replace its contents with the following code:
3737

3838
```cpp
39-
#pragma once
40-
#include <utility>
41-
#include <vector>
42-
43-
template<size_t> struct S1 {};
44-
template<int n> using type = std::vector<S1<n>>;
45-
46-
template<size_t...> struct S2 {};
47-
48-
template<typename> struct S3 {};
49-
50-
template<size_t... n>
39+
#pragma once
40+
41+
#include <utility>
42+
#include <vector>
43+
44+
template<size_t> struct S1 {};
45+
template<int n> using type = std::vector<S1<n>>;
46+
47+
template<size_t...> struct S2 {};
48+
49+
template<typename> struct S3 {};
50+
51+
template<size_t... n>
5152
struct S3<std::index_sequence<n...>>
52-
{
53-
using type = S2<sizeof(type<n>)...>;
54-
};
55-
53+
{
54+
using type = S2<sizeof(type<n>)...>;
55+
};
56+
5657
inline size_t LargeValue()
57-
{
58-
return sizeof(S3<std::make_index_sequence<1000>>);
59-
};
60-
58+
{
59+
return sizeof(S3<std::make_index_sequence<1000>>);
60+
}
61+
6162
inline size_t SmallValue()
62-
{
63-
return sizeof(S1<5>);
64-
}
63+
{
64+
return sizeof(S1<5>);
65+
}
6566
```
6667

6768
1. Create a source file named `LargeValue.cpp`, then replace its contents with the following code:
6869

6970
```cpp
70-
#include "Templates.h"
71+
#include "Templates.h"
7172

7273
size_t GetLargeValue()
73-
{
74-
return LargeValue();
75-
}
74+
{
75+
return LargeValue();
76+
}
7677
```
7778

7879
1. Replace the contents of the `TemplateAnalysis.cpp` file with the following code:
7980

8081
```cpp
81-
#include "Templates.h"
82+
#include "Templates.h"
8283

8384
extern size_t GetLargeValue();
8485

8586
size_t GetSmallValue()
86-
{
87-
return SmallValue();
87+
{
88+
return SmallValue();
8889
}
8990

9091
int main()
@@ -107,7 +108,7 @@ Template instantiation time collection is off by default to minimize build overh
107108

108109
:::image type="content" source="./media/tools-options-build-insights.png" alt-text="Screenshot of the project property pages dialog. The settings are open to Build Insights > Trace Collection. The Collect Template Instantiation checkbox is selected.":::
109110

110-
> [!Note]
111+
> [!NOTE]
111112
> Collecting template instantiation times increases build time due to the extra data collected. Only enable it when you want to analyze template instantiation bottlenecks.
112113
113114
## Run Build Insights to get template instantiation data
@@ -128,7 +129,7 @@ The **Templates** view lists the template instantiations that contributed signif
128129
- **Instantiation File Name** shows where the template is defined.
129130

130131
:::image type="complex" source="./media/templates-view-before-fix.png" alt-text="Screenshot of the Build Insights Templates view showing expensive template instantiations." lightbox="./media/templates-view-before-fix.png":::
131-
The Templates view shows two template instantiations of struct S3 taking most (79.448 percent) of the build time. The Translation Unit column shows that both LargeValue.cpp and SmallValue.cpp are affected. The build time is 4.066 seconds.
132+
The Templates view shows two template instantiations of struct S3 taking most (79.448 percent) of the build time. The Translation Unit column shows that both LargeValue.cpp and TemplateAnalysis.cpp are affected. The build time is 4.966 seconds.
132133
:::image-end:::
133134

134135
- Sort by **Time** to find the templates that take the longest to instantiate.
@@ -146,7 +147,7 @@ To interpret the **Templates** view results:
146147

147148
## Improve build time by optimizing template instantiations
148149

149-
In the example, two template instantiations of `S3` take 79 percent of the build time. The **Translation Unit** column shows that both `SmallValue.cpp` and `LargeValue.cpp` cause this template instantiation.
150+
In the example, two template instantiations of `S3` take 79 percent of the build time. The **Translation Unit** column shows that both `LargeValue.cpp` and `TemplateAnalysis.cpp` cause this template instantiation.
150151

151152
The **Instantiation File Name** and the **Specialization Name** are the same for both entries, which means one expensive template instantiation that affects both source files. That's why the time for each of the two template instantiations is roughly equal. Including `Templates.h` in both source files causes one template instantiation to add significant time to the build.
152153

@@ -156,7 +157,7 @@ From the **Specialization Name** column, the expensive instantiation is `S3<std:
156157
inline size_t LargeValue()
157158
{
158159
return sizeof(S3<std::make_index_sequence<1000>>);
159-
};
160+
}
160161
```
161162

162163
There are three main ways to decrease the cost of template instantiations.
@@ -231,4 +232,4 @@ For more advanced template optimization techniques, see [Build Throughput Series
231232
- [Troubleshoot header file impact on build time](build-insights-included-files-view.md)
232233
- [Troubleshoot function inlining on build time](build-insights-function-view.md)
233234
- [Build Insights now available in Visual Studio 2022](https://devblogs.microsoft.com/cppblog/build-insights-now-available-in-visual-studio-2022)
234-
- [Build throughput series: More efficient template metaprogramming](https://devblogs.microsoft.com/cppblog/build-throughput-series-more-efficient-template-metaprogramming)
235+
- [Build throughput series: More efficient template metaprogramming](https://devblogs.microsoft.com/cppblog/build-throughput-series-more-efficient-template-metaprogramming)

docs/c-runtime-library/acmdln-tcmdln-wcmdln.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
---
2-
description: "Learn more about: _acmdln, _tcmdln, _wcmdln"
32
title: "_acmdln, _tcmdln, _wcmdln"
4-
ms.date: "11/04/2016"
3+
description: "Learn more about: _acmdln, _tcmdln, _wcmdln"
4+
ms.date: 11/04/2016
55
api_name: ["_wcmdln", "_acmdln"]
66
api_location: ["msvcrt.dll"]
77
api_type: ["DLLExport"]
88
topic_type: ["apiref"]
99
f1_keywords: ["_acmdln", "_wcmdln", "_tcmdln"]
1010
helpviewer_keywords: ["_wcmdln global variable", "wcmdln global variable", "_acmdln global variable", "_tcmdln global variable", "tcmdln global variable", "acmdln global variable"]
11-
ms.assetid: 4fc0a6a0-3f93-420a-a19f-5276061ba539
1211
---
1312
# `_acmdln`, `_tcmdln`, `_wcmdln`
1413

@@ -24,6 +23,7 @@ wchar_t * _wcmdln;
2423
#define _tcmdln _wcmdln
2524
#else
2625
#define _tcmdln _acmdln
26+
#endif
2727
```
2828

2929
## Remarks
@@ -32,4 +32,4 @@ These CRT internal variables store the complete command line. They're exposed in
3232

3333
## See also
3434

35-
[Global variables](./global-variables.md)
35+
[Global variables](global-variables.md)

0 commit comments

Comments
 (0)