我想知道以下两种场景对本机C++代码是否有相同的性能影响(如果有任何性能影响)。
让我们假设我有一个函数cpp_calc(),它执行一些计算工作,并且是用本机C++编写的。还有cs_show_gui_stuff(),它是用C#编写的。
现在,下列哪种方案会使本机c++性能恶化(如果有任何性能损失的话)?
Creating a .Net ( C# )应用程序,它运行cs_show_gui_stuff()并在本机C++ dll中使用DllImport调用cpp_calc(),或将C++转换为COM C++,C++应用程序在C++中实现cpp_calc(),并通过将C#代码放置在.Net COM D
我用C++编写了两个非常简单的代码,用C#编写了c#代码
for (int counter = 0; counter < 100000; counter ++)
{
String a = "";
a = "xyz";
a = a + 'd';
a = a + 'c';
a = a + 'h';
}
在c++中
for (int counter = 0; counter < 100000; counter ++)
{
string a = ""
我现在正在学习C++,我听说了很多关于嵌入式脚本语言的知识。我想象的完全不同。
我想我应该用C++编写我的所有性能很重的函数,并将它们从脚本语言(如Lua或Python )中调用。
但情况似乎正好相反。->用Lua/Python编写函数并在C代码中调用它们。
在C++中嵌入一种语言而不是用C++编写API和用另一种语言调用这些函数有什么好处呢?
示例:
// function in c++
int expensiveFunction(){
return 1;
}
然后,在Python中,我会调用这个函数,我可以从C++获得性能,但是由于Python的运行时解释器,我可以在运行时进行更
当我开始学习如何测试一个程序时,我学到的就是用与测试程序相同的语言使用一个库或包。例如,
- if a tested program is written in Python, its testing program is also written in Python and uses `UnitTest` class in the python standard library
- if a tested program is written in C++, its testing program is also written in C++ and uses some test