I am creating an extension for Visual Studio 2008, and because I didn't want to write my own parser for C++ (I'm not masochistic) I am using VCCodeModel.
Getting a simple field from these COM objects takes orders of magnitude more time than any of the other operations I am doing, and since I am drilling down to the method level of very large C++ projects I have this inefficiency at the lowest levels of my recursion.
vcCodeBaseFunctions = ((Microsoft.VisualStudio.VCCodeModel.VCCodeElements)
(vcCM.Functions));
int i = 0;
for (i = 1; i <= vcCodeBaseFunctions.Count; i++)
{
if (vcCodeBaseFunctions.Item(i).Kind == vsCMElement.vsCMElementFunction)
parent.AppendChild(MethodWrapper.VCCodeFunctionToXML(
(VCCodeFunction)vcCodeBaseFunctions.Item(i)));
}
The preceding code would iterate through all of the functions at the base level of a project, convert them to XML and then save them. The XML method would call multiple fields inside the VCCodeFunction like name, parameters, etc.
Is managed C++ faster than C# for this purpose? I have an inadequate understanding of how the back end of managed C++ is different than C#, but my intuition would lead me to believe that there is less of a "context switch" cost between managed and unmanaged code in C++, but am I wrong? I am getting a good bit of slowdown from what I believe is switching repeatedly between managed and unmanaged code in C++ using CodeModel, so am I correct in assuming that managed C++ would be faster?