> If your app is slow because the inefficiencies have added up across the entire codebase (more common, I would argue), that's not an easy option.
This is where I would have to disagree, in my experience, that is less common. Generally there are specific places that are hot spots, and you can just optimize those.
Could be it depends what application you are writing, I tend to write backend services and web apps, for those I've not really seen the "inefficiencies have added up", generally if you profile you'll find a few places that are your offenders.
"Slow" is also very relative.
(cr/quick-bench (reduce (constantly nil) times-vector))
Execution time mean : 3.985765 ms
(cr/quick-bench (dotimes [i (.size times-arraylist)]
(.get times-arraylist i)))
Execution time mean : 775.562574 µs
(cr/quick-bench (dotimes [i (alength times-array)]
(aget times-array i)))
Execution time mean : 590.941280 µs
Yes iterating over a persistent vector of Integers is slower compared to ArrayList and Array, about 5 to 8 times slower. But for a vector of size 1000000 it only takes 4ms to do so.
In Python:
> python3 -m timeit "for i in range(1000000): None"
20 loops, best of 5: 12.1 msec per loop
It take 12ms for example.
So I would say for most uses, persistent vectors serve as a great default mix of speed and correctness.
This is where I would have to disagree, in my experience, that is less common. Generally there are specific places that are hot spots, and you can just optimize those.
Could be it depends what application you are writing, I tend to write backend services and web apps, for those I've not really seen the "inefficiencies have added up", generally if you profile you'll find a few places that are your offenders.
"Slow" is also very relative.
Yes iterating over a persistent vector of Integers is slower compared to ArrayList and Array, about 5 to 8 times slower. But for a vector of size 1000000 it only takes 4ms to do so.In Python:
It take 12ms for example.So I would say for most uses, persistent vectors serve as a great default mix of speed and correctness.