Profile and optimize a slow function
Analyse time and space complexity, then rewrite a bottleneck function using caching, memoization, or a better algorithm. Includes a before/after benchmark.
Preview
Copy prompt
This function is a performance bottleneck in the application: [Paste code]. Analyse its time and space complexity, identify the most expensive individual operations, and rewrite it to run significantly faster. Where applicable suggest caching with memoization, lazy evaluation, or a superior algorithm. Provide a benchmark comparing the before and after using pseudocode or real test cases with representative input sizes.
More
Performance
Prompts
