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

Device detector2 cache #303

Closed

Conversation

cbonte
Copy link
Contributor

@cbonte cbonte commented Jun 7, 2014

This patch provides an optimization that caches the parsed DeviceDetector.

Using The DeviceDetector2 branch, before the patch, a test case with 100000 line extracted from a real website, the result was :

Total time: 308 seconds
Requests imported per second: 323.87 requests per second

After the patch :

Total time: 144 seconds
Requests imported per second: 690.84 requests per second

The optimization really depends on the number of different user agents and the bulk size but in the worst case, we can expect nearly the same performance as without the patch.

Note : initially, I expected to provide the patch for the master branch but I prefered to provide one for the DeviceDetector2 branch, using CacheStatic instead of a static array.

In bulk requests, the same user agent can be seen several times. We can cache
the DeviceDetector instance once parsed to reduce the number of regexes
processed.
@cbonte cbonte closed this Jun 7, 2014
@cbonte cbonte deleted the DeviceDetector2-Cache branch June 7, 2014 22:39
@cbonte
Copy link
Contributor Author

cbonte commented Jun 7, 2014

Pull Request aborted, I realized I pushed a debug test...

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

Successfully merging this pull request may close these issues.

None yet

2 participants