问题描述
您好,
我有一个测试用例,我看到编译过程中性能下降(与VS2012相比)和VS2013)当测试用例涉及结构数组的大型结构的初始化时。
I've a test case where I see a performance degradation during compilation(as compared to to VS2012 and VS2013) when a test case involves initialization of a large structure of structure arrays.
我的程序如下所示:
typedef signed char int8_T;
typedef short int16_T;
typedef int int32_T;
typedef signed char int8_T;
typedef short int16_T;
typedef int int32_T;
typedef struct {
int32_T d;
int32_T e;
} a;
typedef struct {
int16_T f;
int16_T g;
} b;
typedef struct {
int8_T h;
int8_T i;
} c;
typedef struct {
int32_T d;
int32_T e;
} a;
typedef struct {
int16_T f;
int16_T g;
} b;
typedef struct {
int8_T h;
int8_T i;
} c;
typedef struct {
typedef struct {
一个struct_array1 [45003];
a struct_array1[45003];
一个struct_array2 [45003];
a struct_array2[45003];
..... / *多个结构数组a,b, c * /
...../*Multiple structure arrays of type a,b,c*/
} Parent_struct;
} Parent_struct;
const Parent_struct p = {
const Parent_struct p= {
{{ - 123456,87653},{26933323,-8972426}}
{{-123456,87653}, { 26933323, -8972426 }}
/ *多了* /
}
用于编译测试用例的选项:cl -c test.c
Option used to compile the test case : cl -c test.c
当我用不同的编译器计算上面测试用例的编译时间,这就是我发现的:
When I timed the compilation time of above test case with different compilers , this is what I find :
编译器版本 拍摄时间
Visual Studio 2012 ~9s
Visual Studio 2013 ~9s
Visual Studio 2015 ~19s
Visual Studio 2017 ~30s
Compiler Version Time Taken
Visual Studio 2012 ~ 9s
Visual Studio 2013 ~ 9s
Visual Studio 2015 ~ 19s
Visual Studio 2017 ~ 30s
从上面可以看出,与VS2012和VS2013相比,rmance非常低。
As you can see from the above , the performance is very low compared to VS2012 and VS2013.
有人可以建议解决方案或解决方法以克服回归吗?
Can anybody please suggest a solution or a workaround to overcome the regression ?
感谢任何帮助。
谢谢。
推荐答案
欢迎来到MSDN论坛。
Welcome to MSDN forum.
为了在Visual Studio 2017/2015中获得更好的性能,可以应用某种性能调整,如下所示:
- 在工具
下设置当前源控件 ... 为None → 选项
→ 源代码管理。
- 取消选中工具下的同步设置选项 → 选项
→ 环境
→ 同步设置。 - 禁用CodeLens (可选):取消选中工具
下的启用CodeLens选项 → 选项
→ 文本编辑器 → 所有语言。 - 禁用诊断工具(可选):取消选中工具$ b $下的调试时启用诊断工具选项b → 选项
→ 调试 → 一般。 - 清理内容以下文件夹(不要删除这些文件夹,而只是删除它们的内容)并重新启动Visual Studio:
- C:\ Users \<您的用户名称> ; \ AppData \本地\ Microsoft /\\VisualStudio \\ 14.0
- C:\Users \<您的用户名> \ AppData \ Rooaming \ Microsoft's\VisualStudio \ 14.0
- Set Current source control … to None under Tools→ Options → Source Control.
- Uncheck Synchronized settings across ... option under Tools → Options→ Environment → Synchronized Settings.
- Disable CodeLens (Optional): Uncheck Enable CodeLens option under Tools→ Options → Text Editor → All Languages.
- Disable Diagnostic Tools (Optional): Uncheck Enable Diagnostic Tools while debugging option under Tools→ Options → Debugging → General.
- Clean the contents in the following folders (do not delete these folders, instead delete their contents only) and restart Visual Studio:
- C:\Users\<your users name>\AppData\Local\Microsoft\VisualStudio\14.0
- C:\Users\<your users name>\AppData\Roaming\Microsoft\VisualStudio\14.0
祝你好运,
Joyce
这篇关于结构数组初始化时Visual Studio 2015性能下降的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!