Chuyển đến nội dung
Skillpedia
Triển khai và đám mây (DevOps)48k · #5430

performance-optimizer

Skill này làm gì

Công cụ này giúp tìm và sửa các phần chậm trong mã, cơ sở dữ liệu hoặc API của bạn. Nó đo hiệu suất trước và sau để đảm bảo đã có cải thiện.

Khi nào nên dùng

  • ✓Khi một ứng dụng chậm hoặc giật lag.
  • ✓Khi người dùng phàn nàn về tốc độ.
  • ✓Khi các trang mất quá nhiều thời gian để tải.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/performance-optimizer/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/performance-optimizer/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Website của tôi rất chậm, bạn có thể giúp tôi tối ưu tốc độ tải không?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Trước hết, công cụ đo xem một việc nào đó nhanh hay chậm. Sau đó, nó tìm các điểm nghẽn (những phần gây chậm) và đề xuất hoặc áp dụng sửa lỗi. Cuối cùng, nó đo lại để xác nhận cải thiện.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Performance Optimizer

Find and fix performance bottlenecks. Measure, optimize, verify. Make it fast.

When to Use This Skill

  • App is slow or laggy
  • User complains about performance
  • Page load times are high
  • API responses are slow
  • Database queries take too long
  • User mentions "slow", "lag", "performance", or "optimize"

The Optimization Process

1. Measure First

Never optimize without measuring:

// Measure execution time
console.time('operation');
await slowOperation();
console.timeEnd('operation'); // operation: 2341ms

What to measure:

  • Page load time
  • API response time
  • Database query time
  • Function execution time
  • Memory usage
  • Network requests

2. Find the Bottleneck

Use profiling tools to find the slow parts:

Browser:

DevTools → Performance tab → Record → Stop
Look for long tasks (red bars)

Node.js:

node --prof app.js
node --prof-process isolate-*.log > profile.txt

Database:

EXPLAIN ANALYZE SELECT * FROM users WHERE email = 'test@example.com';

3. Optimize

Fix the slowest thing first (biggest impact).

Common Optimizations

Database Queries

Problem: N+1 Queries

// Bad: N+1 queries
const users = await db.users.find();
for (const user of users) {
  user.posts = await db.posts.find({ userId: user.id }); // N queries
}

// Good: Single query with JOIN
const users = await db.users.find()
  .populate('posts'); // 1 query

Problem: Missing Index

-- Check slow query
EXPLAIN SELECT * FROM users WHERE email = 'test@example.com';
-- Shows: Seq Scan (bad)

-- Add index
CREATE INDEX idx_users_email ON users(email);

-- Check again
EXPLAIN SELECT * FROM users WHERE email = 'test@example.com';
-- Shows: Index Scan (good)

**Problem: SELECT ***

// Bad: Fetches all columns
const users = await db.query('SELECT * FROM users');

// Good: Only needed columns
const users = await db.query('SELECT id, name, email FROM users');

Problem: No Pagination

// Bad: Returns all records
const users = await db.users.find();

// Good: Paginated
const users = await db.users.find()
  .limit(20)
  .skip((page - 1) * 20);

API Performance

Problem: No Caching

// Bad: Hits database every time
app.get('/api/stats', async (req, res) => {
  const stats = await db.stats.calculate(); // Slow
  res.json(stats);
});

// Good: Cache for 5 minutes
const cache = new Map();
app.get('/api/stats', async (req, res) => {
  const cached = cache.get('stats');
  if (cached && Date.now() - cached.time < 300000) {
    return res.json(cached.data);
  }
  
  const stats = await db.stats.calculate();
  cache.set('stats', { data: stats, time: Date.now() });
  res.json(stats);
});

Problem: Sequential Operations

// Bad: Sequential (slow)
const user = await getUser(id);
const posts = await getPosts(id);
const comments = await getComments(id);
// Total: 300ms + 200ms + 150ms = 650ms

// Good: Parallel (fast)
const [user, posts, comments] = await Promise.all([
  getUser(id),
  getPosts(id),
  getComments(id)
]);
// Total: max(300ms, 200ms, 150ms) = 300ms

Problem: Large Payloads

// Bad: Returns everything
res.json(users); // 5MB response

// Good: Only needed fields
res.json(users.map(u => ({
  id: u.id,
  name: u.name,
  email: u.email
}))); // 500KB response

Frontend Performance

Problem: Unnecessary Re-renders

// Bad: Re-renders on every parent update
function UserList({ users }) {
  return users.map(user => <UserCard user={user} />);
}

// Good: Memoized
const UserCard = React.memo(({ user }) => {
  return <div>{user.name}</div>;
});

Problem: Large Bundle

// Bad: Imports entire library
import _ from 'lodash'; // 70KB

// Good: Import only what you need
import debounce from 'lodash/debounce'; // 2KB

Problem: No Code Splitting

// Bad: Everything in one bundle
import HeavyComponent from './HeavyComponent';

// Good: Lazy load
const HeavyComponent = React.lazy(() => import('./HeavyComponent'));

Problem: Unoptimized Images

<!-- Bad: Large image -->
<img src="photo.jpg" /> <!-- 5MB -->

<!-- Good: Optimized and responsive -->
<img 
  src="photo-small.webp" 
  srcset="photo-small.webp 400w, photo-large.webp 800w"
  loading="lazy"
  width="400"
  height="300"
/> <!-- 50KB -->

Algorithm Optimization

…

Câu hỏi thường gặp

“Điểm nghẽn” hiệu suất là gì?

Đó là phần của hệ thống (mã, cơ sở dữ liệu, v.v.) gây chậm và hạn chế tốc độ chung.

Tôi có cần biết lập trình để dùng công cụ này không?

Không nhất thiết. Bạn có thể yêu cầu AI xác định vấn đề và đề xuất giải pháp, hoặc thậm chí thử áp dụng sửa lỗi cho mã mà bạn hiểu.

Công cụ biết tối ưu đã có tác dụng bằng cách nào?

Nó so sánh các số đo tốc độ trước và sau khi tối ưu. Nếu tốc độ được cải thiện, việc tối ưu đã thành công.

Chi tiết

Mô tả gốc của tác giả

Identifies and fixes performance bottlenecks in code, databases, and APIs. Measures before and after to prove improvements.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#5430
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự