소스 정보
- 저장소
- ffsshhttiikk/opencode-agents-skills
- 최근 소스 활동
- 2026년 2월 28일 22:53
- 감지된 SKILL.md 언어
- 영어
- 스타
- 2
- 포크
- 2
설치 방법
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
소스 파일 검토
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
메뉴
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/ffsshhttiikk/opencode-agents-skills --skill performance-optimization명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SOC 직업 분류 기준
SKILL.md 표시 중
| name | performance-optimization |
| description | Performance optimization techniques and best practices |
| license | MIT |
| compatibility | opencode |
| metadata | {"audience":"developers","category":"performance"} |
When optimizing application performance or debugging slow code.
import cProfile
import pstats
import memory_profiler
import time
from functools import wraps
import line_profiler
def profile_function(profile_file: str = "profile.prof"):
"""Decorator to profile function execution."""
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
profiler = cProfile.Profile()
profiler.enable()
result = func(*args, **kwargs)
profiler.disable()
profiler.dump_stats(profile_file)
# Print stats
stats = pstats.Stats(profiler)
stats.sort_stats('cumulative')
stats.print_stats(20)
return result
return wrapper
return decorator
@profile_function()
def slow_function():
"""Example slow function."""
data = []
for i in range(10000):
data.append(i * 2)
return sum(data)
# Memory profiling
@memory_profiler.profile
def memory_intensive():
"""Profile memory usage."""
large_list = [i for i in range(1000000)]
return sum(large_list)
# Line-by-line profiling
def profile_lines():
profiler = line_profiler.LineProfiler()
profiler.add_function(slow_function)
profiler.enable()
slow_function()
profiler.disable()
profiler.print_stats()
# N+1 Query Problem
# BAD - N+1 queries
def get_all_users_with_posts():
users = db.query(User).all() # 1 query
result = []
for user in users: # N queries!
posts = db.query(Post).filter_by(user_id=user.id).all()
result.append({'user': user, 'posts': posts})
return result
# GOOD - eager loading
def get_all_users_with_posts():
# Single query with JOIN
users = (
db.query(User)
.options(joinedload(User.posts))
.all()
)
return [{'user': user, 'posts': user.posts} for user in users]
# GOOD - select in load
def get_all_users_with_posts():
users = db.query(User).all()
# Batch load posts
user_ids = [u.id for u in users]
posts = db.query(Post).filter(Post.user_id.in_(user_ids)).all()
posts_by_user = {}
for post in posts:
posts_by_user.setdefault(post.user_id, []).append(post)
return [
{'user': user, 'posts': posts_by_user.get(user.id, [])}
for user in users
]
# Index optimization
class :
():
indexes = [
,
,
,
,
]
idx indexes:
db.execute(idx)
from functools import lru_cache
from cachetools import TTLCache, LRUCache
# Function-level caching
@lru_cache(maxsize=128)
def expensive_computation(n: int) -> int:
"""Cache expensive function results."""
result = sum(range(n))
return result
# Time-based caching
class TTLCache:
def __init__(self, ttl_seconds: int = 300, maxsize: int = 1000):
self.cache = TTLCache(maxsize=maxsize, ttl=ttl_seconds)
def get(self, key: str):
return self.cache.get(key)
def set(self, key: str, value):
self.cache[key] = value
# Query result caching
class QueryCache:
def __init__(self, cache: TTLCache):
self.cache = cache
def get_or_set(
self,
query_key: ,
query_func: ,
ttl: =
):
query_key .cache:
.cache[query_key]
result = query_func()
.cache[query_key] = result
result
:
():
.cache = cache
.subscriptions = {}
():
.subscriptions[key_pattern] = callback
():
.cache.pop(key, )
pattern, callback .subscriptions.items():
._matches(key, pattern):
callback(key)
() -> :
fnmatch
fnmatch.fnmatch(key, pattern)
import asyncio
from concurrent.futures import ThreadPoolExecutor
from typing import List
class AsyncBatchProcessor:
"""Process items in batches for efficiency."""
def __init__(self, batch_size: int = 100):
self.batch_size = batch_size
async def process_items(self, items: List[dict]) -> List[dict]:
"""Process items in batches."""
results = []
for i in range(0, len(items), self.batch_size):
batch = items[i:i + self.batch_size]
batch_results = await self._process_batch(batch)
results.extend(batch_results)
return results
async def _process_batch(self, batch: List[dict]) -> List[dict]:
"""Process single batch."""
return await asyncio.gather(
*[self._process_item(item) for item in batch]
)
() -> :
item
:
():
.executor = ThreadPoolExecutor(max_workers=max_workers)
() -> []:
loop = asyncio.new_event_loop()
tasks = [
loop.run_in_executor(.executor, ._cpu_task, item)
item items
]
loop.run_until_complete(asyncio.gather(*tasks))
() -> :
((n))
import gc
from typing import Generator
import sys
class MemoryOptimizer:
"""Optimize memory usage."""
@staticmethod
def get_memory_usage():
"""Get current memory usage in MB."""
import psutil
process = psutil.Process()
return process.memory_info().rss / 1024 / 1024
@staticmethod
def force_garbage_collection():
"""Force garbage collection."""
gc.collect()
@staticmethod
def disable_garbage_collection():
"""Disable GC for performance-critical sections."""
gc.disable()
@staticmethod
def enable_garbage_collection():
"""Re-enable garbage collection."""
gc.enable()
# Generator for lazy evaluation
def process_large_file(file_path: str) -> Generator[dict, None, None]:
"""Process file line by line without loading entire file."""
with open(file_path, 'r') as f:
for line in f:
yield parse_line(line)
# Chunked processing
def ():
i (, (data), chunk_size):
data[i:i + chunk_size]
:
__slots__ = [, , ]
():
.name = name
.value = value
.timestamp =
zlib
() -> :
zlib.compress(data, level=)
() -> :
zlib.decompress(data)
1. Measure before optimizing
- Profile to find actual bottlenecks
- Don't guess performance issues
2. Use appropriate data structures
- Choose O(1) vs O(n) operations
- Use sets for membership testing
3. Batch operations
- Reduce round trips
- Use bulk operations
4. Lazy loading
- Defer expensive operations
- Use generators
5. Caching
- Cache expensive computations
- Use appropriate TTL
6. Connection pooling
- Reuse database connections
- Reuse HTTP connections
7. Async I/O
- Non-blocking for I/O-bound
- Parallel for CPU-bound
8. Monitor in production
- Track performance metrics
- Alert on degradation