Closed umamaistempo closed 7 years ago
How are you running your benchmarks? Have you put the code snippet above in a file? Or are you running it in IEx?
I was running directly on IEX. Used only timer:tc/1 to "benchmark"
@mememori definitely try to benchmark this from a compiled module and not from IEx, as benchmarks from IEx are usually not reliable.
Ok. I'll do it later and update this issue :grin:
Yes, the code on IEx is evaluated so it may suffer very high fluctuations. In particular, I could not reproduce such a drastic difference here (there is a difference but a certain difference is expected). Thank you!
Just commenting here to confirm this was a false flag, when the code is compiled from a file, the behaviour is not triggered in my setup.
Thank you for your help, josevalim and whatyouhide :grin:
Environment
Elixir 1.3.4 | Erlang/OTP 19
Current behavior
When you pass the param
into: ""
to a comprehension, the length of the strings that are joined affects the time it takes to execute the blockExpected behavior
No significant difference
Example code
Results on my machine:
As you can see, the only difference between the three different comprehensions is the
into
part. When using a non-empty bitstring or a bound string, the result, as expected, doesn't suffer of a considerable performance hit; in the case of an unbound empty bitstring, there is a crescent cost based on the length of the input.Note that, as shown above, this strange behaviour only happens when you meet the following criteria: 1) The comprehension has the
into: ""
param 2) The comprehension traverses a very large list or a list of long strings