Help understanding time complexity

It really depends on what the inputs to the function l_i_s are. It looks like the envelopes consist of fixed size elements from a quick glance.

So then I would estimate it as:

  1. Enum.map - list_to_tuple → O(n)
  2. Enum.sort_by - probably O(n log n)
  3. Enum.map - O(n)
  4. l_i_s → Depends on length of the list. If it’s a fixed size list, would take it as O(n) otherwise O(n^2).

So when we’re adding big-O notation, 1 + 3 just end up being 2*O(n) which is just O(n). The complexity would be dominated by the sort O(n log n) or l_i_s (might be O(n) or O(n^2)).

Regarding time complexity and performance, you would also have to assign some sort of time to each of the function calls and know roughly the max elements of the envelope vs the elements fed to l_i_s. For instance, it could be an O(n^2) for microsecond calls vs O(n) for millisecond calls. Or it could be the sort is the most expensive. Tough to really say from just looking at the code without an idea of the data being fed into it.