uap-go
uap-go copied to clipboard
Optimize for top-user-agents
Teaches the build script to clone top UAs and optimize the matching order accordingly. This leads to huge speedups in real-world (browser) usage.
I'm not against optimization, but this makes the implementation more complicated - do you have any numbers to justify this change? I'd really love a current team/person depending on this library to weigh in..
I don't think it makes the implementation more complicated - all it does is reorder the list of regexes we test against. In fact, the library implementation is exactly the same. The diff looks big because my editor ran gofmt
and removed oddities like trailing semicolons, etc.
As for numbers, I believe I saw around 100x+ speedup on UA parsing, with this change UA parsing disappears from profiles. Intuitively, it makes sense that testing the conditions that are likeliest to match upfront will result in better performance.