PHP formatting speed

First I will give a link to the code: http://ideone.com/6k8R6

On my Intel Core 2 Duo, the result of PHP 5.4.6 is:
usort: 7.8763520717621
quicksort: 2.9220938682556
( usort slower than quicksort )

But on Ideone, the result is:
usort: 0.0313699245453
quicksort: 0.0621209144592
( usort faster than quicksort )

I also checked the code on my friend's computer (Intel Core i5, PHP 5.4.4) and usort also faster.

My question is: why is quicksort sometimes faster than usort and sometimes usort faster?

+6
source share
1 answer

Quicksort is considered one of the fastest sorting algorithms for unsorted data and the slowest of data already sorted (or almost sorted).

+1
source

Source: https://habr.com/ru/post/923751/


All Articles