uap-go icon indicating copy to clipboard operation
uap-go copied to clipboard

Benchmarks

Open derekperkins opened this issue 7 years ago • 8 comments

In #26, it shows that each op takes ~26ms. Is that still accurate?

derekperkins avatar Nov 08 '16 22:11 derekperkins

Also, it'd be nice to have a semi-recent benchmark in the readme.

derekperkins avatar Nov 08 '16 22:11 derekperkins

We have it in production and it consistently takes ~30-40ms on a t3.micro AWS instance. That's the slowest component in a request. Is there a way to speed it up?

Valve avatar Apr 18 '19 22:04 Valve

We also ran into this. It is by far the most expensive thing in serving a response for our service. Unfortunately, I don't think improving the situation would be easy as most of the time seems to be spent in regexp and any change to the regular expressions would affect other languages as well.

oschwald avatar Jun 05 '19 17:06 oschwald

@oschwald, I was able to drastically reduce the processing by caching the initialized parser. The trick there is to keep only one instance of the parser around, and then the Parse method itself is sufficiently fast (2-3ms in our case). Hope this helps

Valve avatar Jun 06 '19 11:06 Valve

Thanks for the suggestion. We were already caching the parser. I ended up switching us to github.com/avct/uasurfer, which has much better performance.

oschwald avatar Jun 06 '19 12:06 oschwald

@Valve how do you cache the initialized parser? Can you pls some code snippets.

ronbeltran avatar Jul 20 '19 10:07 ronbeltran

https://github.com/ua-parser/uap-go/pull/71 should be a pretty big win. You can switch to my fork if you'd like.

dzbarsky avatar Apr 13 '22 03:04 dzbarsky