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

Comments

Projects
None yet
4 participants
@lanaguanifw

lanaguanifw commented Nov 15, 2015

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

This comment has been minimized.

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

This comment has been minimized.

superlbr commented Jun 10, 2016

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

@serbanghita

This comment has been minimized.

Owner

serbanghita commented Jul 9, 2018

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