2 ms·
Dyalog APL is fast: ¯1↑5e6↑{(⊂⍋⍵)⌷⍵}10e6?⍤⍴100 This finds the median of 10 million "ages" in just under 50 milliseconds. Granted, with this randomly gener
by xelxebar 4y ago
Dyalog APL is fast:
¯1↑5e6↑{(⊂⍋⍵)⌷⍵}10e6?⍤⍴100
This finds the median of 10 million "ages" in just under 50 milliseconds. Granted, with this randomly generated data it's probably doing something smart to avoid a full 10MB allocation, so on a static dataset the performance might be a bit different.
- mlochbaum 4y ago(Former Dyalog implementor) I have 9ms for the actual median calculation, which is much faster than generating the ages. It's a counting sort on 1-byte values: since the counts are so large it can just write results with memset() or an equivalent which is vectorized. You could also get the median from the counts directly, although I'm not sure APL has a way to do those counts that's faster than just sorting.
- pcblues 4y agoLike any Sandra Bullock movie, I can't tell if I have witnessed the funniest or most achingly sad thing I have ever seen. I like both.