Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sensor CXX performance #2206

Closed
guwirth opened this issue Jun 22, 2021 · 7 comments
Closed

Sensor CXX performance #2206

guwirth opened this issue Jun 22, 2021 · 7 comments

Comments

@guwirth
Copy link
Collaborator

guwirth commented Jun 22, 2021

@MarcoWagner: i also have a wxWidgets based project with interesting stats.

~150k LoC
INFO: Sensor CXX [cxx] (done) | time=5.475.497ms

@guwirth
Copy link
Collaborator Author

guwirth commented Jun 22, 2021

Hi @MarcoWagner,

maybe you can turn on debug info and isolate the problem:

Regards,

@MarcoWagner
Copy link

its #2131

@guwirth
Copy link
Collaborator Author

guwirth commented Jun 30, 2021

Hi @MarcoWagner,

could you provide a sample please?

Regards,

@MarcoWagner
Copy link

MarcoWagner commented Jun 30, 2021

#include <iostream>
#include <string>
#include <sstream>

std::ostream& operator< (std::ostream& dest, const std::string& what) { 
   return dest;
}

int main () 
{
   std::string a, b, c, d, e, f;
   std::stringstream dest;
   
   dest < a < b < c < d < e < f;
}

Seems to be O(n!)

That this code is inside a wxWidgets project is just a coincidence

@guwirth
Copy link
Collaborator Author

guwirth commented Jul 1, 2021

Hi @MarcoWagner,

I’m wondering why someone creates an own streaming operator with <? Why not writing <<?

The problem is in the grammar where has to be decided if something like this is a conditional expression or a cascaded template. This construct leads to a lot of backtracking and slow speed. Found up to now no solution to speed that up. The case where something like this ends up in a template is more likely and fast.

Ideas are welcome.

Regards,

@MarcoWagner
Copy link

MarcoWagner commented Jul 1, 2021

I also don't like that operator< and operator> "missuse". cppcheck is also detecting it as an suspicous operator usage und does sometimes alert it as uninitialized variable usage.... But that discussion is out of scope. ;-)

Maybe the parser can detect this construct, warn and skip over?

@guwirth
Copy link
Collaborator Author

guwirth commented Aug 7, 2021

duplicate #2131

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants