I'm not sure if they are mapping every single pixel or using some average pixels, but it's pretty fast.
Here is a shameless plug for one of my color extracting library: https://github.com/jathu/UIImageColors/
It currently takes around ~0.3s on average to extract the colors. However, with my new PR (https://github.com/jathu/UIImageColors/pull/54), it takes around ~0.14s on average. IMO this is still slow, I would like to bring it below 0.1s.
I tried to optimize this with k-means to reduce total number of colors, but the result was slower and worse color choices. If anyone has methods to improve the performance, please make a PR.