연간 연간 결제 시 모든 유료 요금제에서 2개월 무료. 요금제 보기
로그인 무료로 시작

성능 검토

입력
코드
function add(a, b) { return a + b; }
예시 결과 27 10월 2026에 생성됨

Performance review

Hot path complexity

  • Time: O(1) per call.
  • Space: O(1).
  • There are no loops, recursive calls, or input-dependent operations.

Allocation / GC pressure

  • For numeric inputs, the function typically creates no heap allocations, so GC pressure is negligible.
  • If either operand is a string, + performs concatenation and allocates a new string of size O(len(a) + len(b)).
  • Untyped parameters allow mixed operand types, which may introduce coercion and reduce JIT optimization stability at polymorphic call sites.

I/O / N+1 patterns

  • No I/O, network, database, filesystem, or N+1 behavior.

Optimized version

function add(a: number, b: number): number {
  return a + b;
}

Change notes

  • Added numeric parameter and return types: prevents accidental string concatenation and mixed-type usage; can keep hot call sites monomorphic. Expected algorithmic improvement: none (O(1) remains O(1)), but it may avoid O(len(a) + len(b)) string allocation and coercion when callers pass incorrect types.
  • Kept the implementation direct: function-call overhead may be inlined by modern JavaScript engines. Further micro-optimization is unlikely to provide a measurable win in normal workloads.
  • GC impact: remains effectively zero for numeric inputs.
이걸로 시작 성능 검토 이 예시의 입력이 채워진 채로 양식이 열립니다. 무엇이든 바꿀 수 있어요.