简体   繁体   English

Linux与Windows 7(VM)C ++执行速度

[英]Linux vs. Windows 7 (VM) C++ Execution Speed

I have a simple machine learning program I wrote in C++ with dlib. 我有一个简单的机器学习程序,我使用dlib在C ++中编写。 On the machine I wrote and tested it on, an ASUS Eee PC with a 1.6 GHz Atom processor running Kali Linux and compiling with g++ via cmake, it runs from start to finish in 2 minutes. 在我编写和测试的机器上,一台运行Kali Linux的1.6 GHz Atom处理器的华硕Eee PC,并通过cmake用g ++编译,它在2分钟内从头到尾运行。 However, in a Windows 7 VM (in VMWare Fusion) running on a Macbook Pro with a 2.3 GHz Core i7, the exact same code, compiled with VS 2013, takes 2 hours to run. 但是,在配备2.3 GHz Core i7的Macbook Pro上运行的Windows 7 VM(VMWare Fusion)中,使用VS 2013编译的完全相同的代码需要2个小时才能运行。 I'm working on a way to implement multi-threading in the code to take advantage of the 4 vCPUs I allocated to the VM but still, the difference in performance is extreme and I haven't been able to figure out the cause. 我正在研究一种在代码中实现多线程的方法,以利用我分配给VM的4个vCPU,但性能上的差异仍然极端,我无法弄清楚原因。 Even accounting for the performance overhead of virtualization I expected the VM to be faster... I feel like I might be missing something obvious. 即使考虑到虚拟化的性能开销,我也希望VM更快......我觉得我可能会遗漏一些明显的东西。 How can I get the execution speed in the VM to at least be on par with the Linux machine? 如何让VM中的执行速度至少与Linux机器相媲美?

Without seeing the source code and profiling it is hard to say (if not impossible), there are many possible reasons. 如果没有看到源代码和分析,很难说(如果不是不可能的话),有很多可能的原因。

1) windows on the VM detect in some way it is running slow (because of VM) so to keep responsive it reduce execution of your code (a way to speed it up in theory is adding a loop that periodically sample user input, the scheduler tend to give more execution time to processes that need interaction) 1)VM上的窗口以某种方式检测到它运行缓慢(因为VM)所以为了保持响应它减少了代码的执行(从理论上讲加快循环的方法是定期对用户输入进行采样,调度程序倾向于给需要交互的进程提供更多的执行时间)

2) VS produced debug/profile symbols, if I remember correct that's the default, and they add a huge overhead (try build release then). 2)VS生成了调试/配置文件符号,如果我记得这是默认的,那么它们会增加很大的开销(然后尝试构建版本)。

3) The overhead is already correct. 3)开销已经正确。 If I remember correctly starting Eclipse on my machine takes somewhat 10 seconds, but 3/4 minutes on the VM (same PC) (approximately I think it has similiar ratio for 2 minutes to several hours.) 如果我记得在我的机器上正确启动Eclipse需要10秒钟,但在VM(同一台PC)上需要3/4分钟(大约我觉得它有2分钟到几个小时的相似比例。)

4) there may be other bottlenecks (like bandwith usage) 4)可能存在其他瓶颈(如带宽使用)

5) you don't know how exactly the VM works internally (but you could do benchmarks for various cases on both machines and see where do you find anomalies) 5)您不知道VM内部的工作原理(但您可以在两台机器上为各种情况做基准测试,看看在哪里发现异常)

6)Curiosity there exists cases where VM is faster (where I remember somone noted a code runned faster on WinE than on Windows, because WinE was using a faster fmod implementation) 6)好奇心存在VM更快的情况(我记得somone注意到WinE上的代码运行速度比Windows快,因为WinE使用更快的fmod实现)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM