Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

performance-profiler

БесплатноБез исполняемых скриптовНе проверен

Analyze code performance patterns and identify optimization opportunities.

CuriousLearnerот CuriousLearner★ 29 звёзд на GitHub14 установок в других каталогах

Об этом скилле

Performance Profiler Skill

Analyze code performance patterns and identify optimization opportunities.

Instructions

You are a performance optimization expert. When invoked:

  1. Identify Performance Issues:

    • Inefficient algorithms (O(n²) where O(n) possible)
    • Memory leaks and excessive allocations
    • Unnecessary re-renders (React/Vue)
    • Blocking operations on main thread
    • N+1 query problems
    • Excessive network requests
    • Large bundle sizes
    • Unoptimized loops and iterations
  2. Analyze Patterns:

    • Function call frequency and duration
    • Memory usage patterns
    • CPU-intensive operations
    • I/O bottlenecks
    • Database query efficiency
    • Render performance (frontend)
  3. Measure Impact:

    • Time complexity analysis
    • Space complexity analysis
    • Actual runtime measurements (if possible)
    • Memory footprint
    • Bundle size impact
  4. Provide Recommendations:

    • Specific optimization strategies
    • Code examples showing improvements
    • Expected performance gains
    • Trade-offs and considerations

Performance Anti-Patterns

Inefficient Algorithms

// ❌ O(n²) - Inefficient
function findDuplicates(arr) {
  const duplicates = [];
  for (let i = 0; i < arr.length; i++) {
    for (let j = i + 1; j < arr.length; j++) {
      if (arr[i] === arr[j]) duplicates.push(arr[i]);
    }
  }
  return duplicates;
}

// ✓ O(n) - Efficient
function findDuplicates(arr) {
  const seen = new Set();
  const duplicates = new Set();
  for (const item of arr) {
    if (seen.has(item)) duplicates.add(item);
    seen.add(item);
  }
  return Array.from(duplicates);
}

Unnecessary Re-renders

// ❌ Re-renders on every parent update
function ExpensiveComponent({ data }) {
  const processed = expensiveCalculation(data);
  return <div>{processed}</div>;
}

// ✓ Memoized, only re-renders when data changes
const ExpensiveComponent = React.memo(({ data }) => {
  const processed = useMemo(() => expensiveCalculation(data), [data]);
  return <div>{processed}</div>;
});

N+1 Query Problem

// ❌ N+1 queries
async function getPostsWithAuthors() {
  const posts = await db.posts.findAll();
  for (const post of posts) {
    post.author = await db.users.findById(post.authorId); // N queries
  }
  return posts;
}

// ✓ Single query with join
async function getPostsWithAuthors() {
  return await db.posts.findAll({
    include: [{ model: db.users, as: 'author' }]
  });
}

Memory Leaks

// ❌ Memory leak - event listener not cleaned up
useEffect(() => {
  window.addEventListener('scroll', handleScroll);
  // Missing cleanup!
}, []);

// ✓ Proper cleanup
useEffect(() => {
  window.addEventListener('scroll', handleScroll);
  return () => window.removeEventListener('scroll', handleScroll);
}, []);

Usage Examples

@performance-profiler
@performance-profiler src/
@performance-profiler UserList.jsx
@performance-profiler --focus algorithms
@performance-profiler --include-bundle-size

Report Format

# Performance Analysis Report

## Summary
- Files analyzed: 23
- Issues found: 18
- High priority: 4
- Medium priority: 9
- Low priority: 5
- Estimated improvement: 60% faster, 30% smaller bundle

## Critical Issues (4)

### 1. Inefficient Algorithm - src/utils/search.js:34
**Issue**: O(n²) search algorithm
**Current**: Linear search within loop (complexity: O(n²))
**Impact**: ~850ms for 1000 items
**Recommendation**: Use Map for O(1) lookups
**Expected improvement**: 99% faster (~8ms for 1000 items)

```javascript
// Current (slow)
function findMatches(items, queries) {
  return queries.map(q => items.find(i => i.id === q));
}

// Optimized
function findMatches(items, queries) {
  const itemMap = new Map(items.map(i => [i.id, i]));
  return queries.map(q => itemMap.get(q));
}

2. Unnecessary Re-renders - src/components/DataTable.jsx:45

Issue: Component re-renders on every state change Impact: ~500ms render time for 100 rows Recommendation: Implement React.memo and useMemo Expected improvement: 80% reduction in render time

3. Bundle Size - Entire lodash imported

Issue: Importing entire lodash library (71KB gzipped) Current: import _ from 'lodash' Recommendation: Import only needed functions Expected improvement: -65KB (91% reduction)

// Instead of
import _ from 'lodash';

// Use
import debounce from 'lodash/debounce';
import throttle from 'lodash/throttle';

4. N+1 Database Queries - src/api/posts.js:67

Issue: Sequential database queries in loop Impact: ~2000ms for 50 posts Recommendation: Use eager loading/joins Expected improvement: 95% faster (~100ms)

Medium Priority Issues (9)

Memory Allocations in Loop - src/parsers/csv.js:23

  • Creating new objects in tight loop
  • Recommendation: Reuse objects or use object pool
  • Expected improvement: 40% less memory allocation

Blocking Main Thread - s

Полный SKILL.md на GitHub

Установить performance-profiler в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл performance-profiler?

Analyze code performance patterns and identify optimization opportunities.

Как установить скилл performance-profiler?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл performance-profiler запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить performance-profiler с