Skip to content

Performance issues #36

@giljulio

Description

@giljulio

Since version 2, we’ve noticed a significant performance drop when using this package for string-to-enum mapping.

In our case, converting large objects causes visible UI freezes for several seconds, making it unsuitable for production use.

Recommendations:

  1. Question the requirements - Is this more complex string to enum features really needed? It adds complexity and it has performance considerations
  2. Optimise simple lookups – The most basic case ('valueSomething3' → Enum.valueSomething3) should be as fast as possible. Avoid regex when possible as it's easily 1000x or more slower.
  3. Avoid unnecessary regex creation – EnumToString.fromString currently creates a new Regex object every time it’s called. Since regex compilation is expensive, caching the compiled regex may improve performance.
  4. Add performance tests – This utility is often used in deserialisation (e.g., JSON parsing) and can be called thousands of times. Small slowdowns can accumulate and severely impact performance. Adding benchmarks would help prevent future regressions. Quick google showed this package could help building this but there may be better ones.

Let me know if I can help review and test potential fixes!

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