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

[question] Performance difference in Query vs standard collection lambda #180

Closed
archenroot opened this issue Jan 13, 2018 · 5 comments
Closed

Comments

@archenroot
Copy link

Hi,

I am now building some basic trading system for personal use and cqengine was my primary choice, really superior stuff :-)

Although I love myself SQL as I come from SQL background I applied in my code in some cases Java streams with .filter() .forEach() etc functions.

Q: Is there any or significant difference between using Java lambdas vs cqengine native Query object? I can and will test myself anyway, but was interested if anyone know this.

Thanks.

@archenroot
Copy link
Author

Ok, I can answer myself I think now after some examination :-). Of course using lambda only based filters possibly will result for performance degradation as soon as those don't use the indexing capabilities which are defined via special methods in the stored objects.

I think without indexes the results are expected to be very similar, but I am not going to write benchmark now.

@npgall
Copy link
Owner

npgall commented Jan 17, 2018

Sorry I've been busy - apologies for my delay replying!

I think a lambda function when filtering a stream is likely to outperform a CQEngine Query object when filtering a stream. However the difference is likely to be minimal, and scalability and time complexity will be O(n) in both cases.

The main reason to use a CQEngine query performance-wise is to leverage indexes. A CQEngine query on an IndexedCollection which has appropriate indexes will have sub-linear time complexity. So it will outperform filtering by a lambda expression.

@archenroot
Copy link
Author

archenroot commented Jan 17, 2018

@npgall - no sorry required here, not a problem, I understand. Your project is briliant I am using in some high performance trading system, if I don't do mistake in trading algorithms, I will donate this brilliant project!

But you actually confirmed my own observations except that lambda on stream will be slightly faster on cqengine collection without indexes, but with indexes cqengine is the winner.

Thanks for your hard work on this.

@archenroot
Copy link
Author

If I will make some good profit with my system I will donate you some crypto coins... ;-)

@npgall
Copy link
Owner

npgall commented Jan 29, 2018

Looking forward! :)

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

No branches or pull requests

2 participants