Closed mugisoba closed 4 years ago
Hmm I shall take a look into the perf, do you feel this has gotten worse than it was before ? or just always has been slow ?
I am also curious how much code are you throwing at it? Is this a larger codebase ?
v0.7.0 is slower than v0.6.0.
I tested with this header file. https://github.com/google/flatbuffers/blob/master/include/flatbuffers/flatbuffers.h
var sw = new System.Diagnostics.Stopwatch();
sw.Start();
for (var i = 0; i < 10; ++i)
{
var options = new CppAst.CppParserOptions().ConfigureForWindowsMsvc(CppAst.CppTargetCpu.X86_64, CppAst.CppVisualStudioVersion.VS2019);
options.Defines.Add("_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH");
options.IncludeFolders.Add(@"flatbuffers\include");
var compilation = CppAst.CppParser.ParseFile(
cppFilename: @"flatbuffers\include\flatbuffers\flatbuffers.h",
options:options);
}
sw.Stop();
Console.WriteLine(sw.Elapsed);
Yikes! I think I know what is causing this behavior! I do think your changes are good anyway and If you could can you add a test:
public void TestCppNoParseOptionsAttributes()
{
ParseAssert(@"
[[noreturn]] void x() {};", compilation =>
{
Assert.False(compilation.HasErrors);
Assert.AreEqual(1, compilation.Functions.Count);
Assert.AreEqual(0, compilation.Functions[0].Attributes.Count);
},
// we are using a C++14 attribute because it can be used everywhere
new CppParserOptions() { AdditionalArguments = { "-std=c++14" }, ParseAttributeEnabled = false }
);
}
Actually, I would prefer if ParseAttributeEnabled
is set to false
by default. We can document it in the readme - as it is done for macros.
I fixed it. Please review it again.
This PR adds the
ParseAttributes
option to skip parsing attributes.ParseFunctionAttributes
andParseAttributes
function takes a long time to complete, so I propose to add an option to skip these functions.