Well ... it seems that planet ocaml is faster then light to index new pages... I often start editing one story to publish it few days later to avoid stupid mistakes. This time I published the page by accident and I think it stayed published for less then two minutes... This is the final versions ...
Today i did a small audit on my code to check which are the functions that are often used and can slow down my code. One in particular took my attention, ExtLib.List.unique . This function (below) takes quadratic time on the length of the input list. On big lists, this function is a killer. The algorithm is very simple. Since it accepts a cmp optional argument, it can be much faster if we use a monomorphic comparing function.
This is a small benchmark (benchmarking is addictive indeed !!) using, the polymorphic and monomorphic variant of List.unique :
However if you want to go even faster, you can use a stupid implementation based on hash tables.
The results are quite clear...
In this test with a long list and many repetition, the difference is remarkable. the function hash_unique is not stable, but if you don't care, it does the job pretty well. If you want an even faster implementation based on list that is also not stable, you can write a small function that remove duplicates on a sorted list.
Recent comments
1 week 5 days ago
2 weeks 3 days ago
4 weeks 1 hour ago
7 weeks 2 days ago
15 weeks 11 hours ago
15 weeks 3 days ago
15 weeks 6 days ago
15 weeks 6 days ago
16 weeks 1 hour ago
16 weeks 1 hour ago