Re: Notice that lists comprehension at least twice as slow

129 views
Skip to first unread message

José Valim

unread,
Jul 21, 2012, 4:45:48 PM7/21/12
to elixir-l...@googlegroups.com
Hello Alex,

Thanks for the benchmarks.

The reason this happens is because our list comprehensions consider everything in filters except false or nil to be true.
So this additional check costs us a bit. We could certainly optimize this though, since operators (like < and >) and other BIFs are known to return just booleans, allowing us to skip this check, I just haven't got to this optimization stage (it surprises me that this check is causing all this difference though).

On Saturday, July 21, 2012 10:22:05 PM UTC+2, Alex Zatvorskiy wrote:
Hey,

I have been doing some benchmarks. So, I have found that elixir's lc at least as slow then erlang's original feature.
There are some benchmarks:


P.S: On the other hands, you should spread your purpose, and roadmap in general.
Stay well )) 

José Valim

unread,
Jul 22, 2012, 4:33:13 AM7/22/12
to elixir-l...@googlegroups.com
Hello Alex,

I have pushed a commit to Elixir master that skips the conversion check if the expression is known to return a boolean:


This brings Elixir's performance to the same level as Erlang's for such common comprehensions.

Cheers!

José Valim
Founder and Lead Developer

Alex Zatvorskiy

unread,
Jul 28, 2012, 9:52:12 AM7/28/12
to elixir-l...@googlegroups.com
Thanks a lot, I'll proceed
Reply all
Reply to author
Forward
0 new messages