Skip to content

Performance issue #150

Description

@kostia1st

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions