Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase the performance (x6) #474

Closed
lanaguanifw opened this issue Nov 15, 2015 · 3 comments
Closed

Increase the performance (x6) #474

lanaguanifw opened this issue Nov 15, 2015 · 3 comments

Comments

@lanaguanifw
Copy link

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/

@RedEars
Copy link

RedEars commented Nov 16, 2015

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

@superlbr
Copy link

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

@serbanghita
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants