Here's a sample code:
const deviceDetector = new DeviceDetector();
const startPoint = performance.now();
deviceDetector.parse('');
console.log(`Time elapsed #1: ${Math.trunc(performance.now() - startPoint)}ms`);
deviceDetector.parse('');
console.log(`Time elapsed #2: ${Math.trunc(performance.now() - startPoint)}ms`);
deviceDetector.parse('');
console.log(`Time elapsed #3: ${Math.trunc(performance.now() - startPoint)}ms`);
Here's the result:
Time elapsed #1: 287ms
Time elapsed #2: 511ms
Time elapsed #3: 514ms
So, I see here a few issues:
- second run takes almost as much time as the first one, but starting with third everything starts to work faster; given there's some kind of lazy cache, I'd expect the second run already be fast;
- overall question - is it OK that a fully locally loaded library takes ~280ms of CPU time to process a simple input string? For the context, I run it on
AMD Ryzen 7 5800HS - which is a relatively capable CPU
Here's a sample code:
Here's the result:
So, I see here a few issues:
AMD Ryzen 7 5800HS- which is a relatively capable CPU