DeviceDetector.NET icon indicating copy to clipboard operation
DeviceDetector.NET copied to clipboard

Slow Initial Parse

Open Mike-E-angelo opened this issue 3 years ago • 4 comments

I wanted to first thank you for a wonderful library and API. It is well-designed and easy to use. It is, in fact, exactly what I am looking for.

The only issue that I have is that it appears the following takes 5 seconds to run the first time (subsequent executions are as expected):

var sut = new DeviceDetector("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36");
sut.Parse();

Is this expected/known behavior? 5 seconds would increase my application startup time by ~25% which would be a drag, so making sure before I do so. :)

Thank you for any assistance/context/insight you can provide.

Mike-E-angelo avatar Feb 23 '22 13:02 Mike-E-angelo

Hi @Mike-E-angelo, Did you try to use Cache or MSRegexCompiledEngine ?

totpero avatar Feb 24 '22 17:02 totpero

Thank you for the reply @totpero. I did try those and it still seems to clock in at over 5 seconds when I run the test:

You can view the test here for your review: https://github.com/DragonSpark/Framework/blob/aec495ab9622e58fc6412beff972c45b793d4543/DragonSpark.Presentation.Testing/IsBotTests.cs#L28-L35

Mike-E-angelo avatar Feb 26 '22 16:02 Mike-E-angelo

the same

asadullazadeh avatar May 17 '22 07:05 asadullazadeh

Did you try the new version 6.1.0? That version contains performance improvements. Im my case the initial parse is much faster.

savage8811 avatar Mar 29 '23 08:03 savage8811