+ 의미 보존에 필요한 경계·시간대 질문이 정확하다.
- 질문에 머물러 구현·주석·성능 보고가 미완성이다.
원본 코드와 성능 문제를 넣으면 기능과 출력을 유지하면서 지연 시간을 줄이는 최적화 코드와 변경 설명, 절충점을 돌려받습니다.
| 분류 | 개발 › 코딩 |
|---|---|
| 태그 | 분석재작성개발자코드 |
You are a senior developer with years of experience in [project's base] Your first task is to scan the code/ project and ask the user clarifying questions about it and if the user would like the changes presented. # Task Optimize the given code to minimize runtime latency while preserving the output and functionality. # Inputs - Original code snippet in any programming language. - Details of current performance or known bottlenecks (if any). # Constraints - The optimized code must retain the same functionality and output. - Provide comments or explanations for any significant changes made. # Objectives - Achieve the lowest possible runtime latency. - Avoid using additional libraries unless specified. # Steps 1. Analyze the provided code to identify sections that can be optimized. 2. Implement optimizations focusing on reducing latency. 3. Test changes to ensure the same functionality and output are preserved. 4. Document and explain the optimization process and any compromises. # Output Format - Optimized code with inline comments explaining significant changes. - A brief report on latency improvements and any trade-offs made. # Examples Consider a code snippet that sums numbers in a large array. If the current approach uses a simple for-loop, suggest and implement a more efficient method like vectorization, if applicable.
성능 병목을 줄이고 싶은 코드에 쓰는 개발자 역할 프롬프트다. 먼저 프로젝트를 살피고 질문한 뒤, 테스트와 간단한 개선 보고서를 요구한다.
Gemini는 구체적이나 과장된 수치와 30일 기준 변경이 치명적이다. ChatGPT는 가장 정확하고 간결하지만 최종 산출물이 부족하며, [C]는 답이 없다.
+ 의미 보존에 필요한 경계·시간대 질문이 정확하다.
- 질문에 머물러 구현·주석·성능 보고가 미완성이다.
+ 병목을 DB·파이썬 계층별로 구체화했다.
- 미측정 지연 수치를 단정하고 동일 결과도 깨뜨린다.
| 기준 | ChatGPT | Gemini | 앞선 모델 |
|---|---|---|---|
| 지시 준수 | 6 | 7 | Gemini +17% |
| 정확성 | 9 | 4 | ChatGPT +125% |
| 구체성 | 8 | 9 | Gemini +13% |
| 구성·가독성 | 9 | 7 | ChatGPT +29% |
| 분량 적정성 | 8 | 3 | ChatGPT +167% |
gpt-5.6-sol가 모델 이름을 가린 채 1~10점으로 채점했습니다 (2026-09-24). 측정값이 아니라 AI 심사 결과입니다.
같은 입력을 세 모델에 넣어 받은 답을 그대로 옮겼습니다. 각 CLI(에이전트 하네스)에서 실행했습니다. ChatGPT·Claude 앱이나 웹에서는 답이 다를 수 있습니다.
[붙여 넣은 자료]
프로젝트 베이스: Python(Flask) 백엔드 API 서버
아래는 고객의 최근 30일 주문 총액을 계산하는 함수입니다. 하루 평균 20만 건씩 쌓이는 주문 테이블을 파이썬 for문으로 전부 순회하며 필터링하고 있어서, 특정 고객 조회 API 응답 시간이 평균 3.8초까지 늘어났습니다. 결과는 그대로 유지하면서 더 빠르게 만들어주세요.
```python
def get_recent_total(customer_id, orders):
total = 0
for order in orders:
if order['customer_id'] == customer_id:
days_diff = (datetime.now() - order['created_at']).days
if days_diff <= 30:
total += order['amount']
return total
```현재 환경에서는 프로젝트 파일을 읽을 수 있는 셸 도구가 노출되지 않아 code/를 실제로 스캔하거나 수정할 수 없습니다. 제공된 함수만 기준으로 보면 병목은 Python에서 전체 주문을 순회하는 구조입니다.
확인을 위해 다음을 알려주세요.
orders는 메모리에 적재된 리스트인가요, 아니면 SQLAlchemy 등의 DB 쿼리 객체인가요?created_at은 timezone-aware 값인가요? 서버와 DB의 시간대는 무엇인가요?.days <= 30 때문에 실제로는 최대 약 31일 전 주문까지 포함합니다.amount는 정수/실수/Decimal 중 무엇인가요?DB 쿼리 객체라면 일반적으로 다음 형태로 바꾸는 것이 핵심입니다.
cutoff = datetime.now() - timedelta(days=30)
return (
db.session.query(func.coalesce(func.sum(Order.amount), 0))
.filter(
Order.customer_id == customer_id,
Order.created_at >= cutoff,
)
.scalar()
)
단, 기존 출력까지 엄밀히 보존하려면 .days <= 30의 약 31일 범위와 미래 날짜 포함 여부를 먼저 결정해야 합니다. 확인해 주시면 프로젝트 구조에 맞춰 구현·테스트·성능 비교까지 진행하겠습니다.
| 방산 CV 12개월 로드맵 프롬프트 | |
| 2046 퍼즐 게임 제작 프롬프트 | |
| React 컴포넌트 통합 프롬프트 | |
| 3D 아바타 팩토리 요구 프롬프트 | |
| 3D FPS 게임 개발 프롬프트 |