Skip to content

Conversation

@codegen-sh
Copy link

@codegen-sh codegen-sh bot commented Apr 3, 2025

This PR adds a script to analyze presenter files (*.presenter.tsx or *.presenter.ts) and identify properties in the VM method that are simple repeats of other properties or props.

Features

  • Finds all presenter files in a directory
  • Analyzes the vm() method in each presenter
  • Identifies properties that are simple repeats of:
    • Props passed to the presenter
    • Other properties in the same VM object

Usage

# Install dependencies
cd scripts
npm install

# Run on a specific directory
npm run analyze -- ./src/components

# Run on the current directory
npm run analyze

Example

The script includes a sample presenter file that demonstrates the analysis. When run on this sample, it correctly identifies properties that are simple repeats of props.

Why This Matters

Identifying redundant property mappings can help:

  1. Simplify presenters
  2. Reduce boilerplate code
  3. Make the intention of the VM clearer
  4. Potentially optimize performance by avoiding unnecessary mappings

@codspeed-hq
Copy link

codspeed-hq bot commented Apr 3, 2025

CodSpeed Performance Report

Merging #76 will degrade performances by 23.73%

Comparing gen/2ac975f9-6620-4486-833f-f8558ba46fb5 (a50c3de) with main (17b4c92)

Summary

❌ 1 regressions
✅ 4 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
parse[3] 3.1 s 4 s -23.73%

Hey! 👋 Taking a look.
💻 View my work.

@codegen-sh
Copy link
Author

codegen-sh bot commented Apr 3, 2025

I've analyzed the performance regression reported by CodSpeed and created a PR with optimizations to address the issue:

🚀 View PR #79 🚀

The optimizations focus on:

  1. Improved File Discovery: Added ignore patterns for common directories to reduce scanning overhead
  2. Optimized AST Traversal: Combined multiple passes into a more efficient single traversal
  3. Memory Efficiency: Processing files in batches to reduce memory pressure
  4. Parsing Improvements: Optimized file content handling and property analysis

These changes should significantly reduce the performance impact on the codebase parsing benchmark while maintaining the same functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant