Not actually fast - #56
Conversation
I use this library on my logfiles. Half of the time is spent looking up IP addresses in a on-disk database, the other half is spent in httpagentparser. The time spent parsing the log file is marginal. This change is obviously meant as a joke, but I suggest you do some profiling. Or I might even do some myself.
pepijndevos
commented
Aug 5, 2014
Extracted bits from a profile of a small sample run of my application. |
pepijndevos
commented
Aug 5, 2014
It seems to be a result of how the library works. It invokes all the detectors one by one to see if they match. This means speed decreases linearly as more browsers are added. So I actually made it twice as slow by contributing a ton of bots and mobile browsers. So the only way to make a real difference is to detect less browsers, or majorly refactor. It's imaginable to arrange browsers in a tree. For example, if a mobile OS is detected, all desktop detectors could be ignored. Or if Webkit is detected, all Gecko and Trident detectors could be ignored. Another wild idea would be to flatten everything into a humongous regex/state machine. This requires more thought and design. Related: https://github.com/clojure/core.match/wiki/Understanding-the-algorithm |
shon
commented
Aug 12, 2014
Will look into this once I am little free from my current work. Unsure how regex based solution will perform. Also if you have any other ideas/POC code please feel free. |
shon
commented
Oct 24, 2014
One quick soltion is moving not so popular agents to existing more.py and making them optional. Would be interesting to see if that makes hap faster? This should really be a issue so more people can notice. |
pepijndevos
commented
Oct 24, 2014
That would make it faster, at the cost of detecting less. |
lenisko
commented
Feb 21, 2018
I have to admit that, it's very slow... |
I use this library on my logfiles.
Half of the time is spent looking up IP addresses in a on-disk database, the other half is spent in httpagentparser.
The time spent parsing the log file is marginal.
This change is obviously meant as a joke, but I suggest you do some profiling. Or I might even do some myself.