serbanghita/Mobile-Detect

Increase the performance (x6)

lanaguanifw opened this issue · 3 comments

Class to increase the performance of Mobile Detect lib.

Mobile Detect uses a loop with regular expressions to determine the device, and PHP is very slow on this. By reducing the size of the string in the regular expression we get increased performance.

The information theory says that the most frequent words provide less information. Then if it appears in 100% of cases the word "Mozilla" can exclude it from the regular expression as it will be irrelevant in determining the device in the User Agent.

What we do is create an array ($irrelevant) with the list of "irrelevant words" to exclude of User Agent.

Source: https://bitbucket.org/lanaguani/mobile-detect-fast/

Great!
I just wanted to post an performance Issue because the original MobileDetect calls the preg_function over 1000 times which takes a lot of time. Thanks to your Class my Wall Time decreased by about 80ms!
Still not perfect, but way better. Thanks alot

Hi,what's up,why not a push to master? Any1 else just did not feel the cold of slowing down....

I like the idea, I cannot add it to the current iteration (2.x) since this version was meant to detect mobile devices and tablets. An optimisation comes with a lot of UA pattern conflicts which I cannot oversee at this point in time. I will add the project to the front page, maybe someone is interested in this topic.