वार्षिक सालाना भुगतान करें और हर सशुल्क प्लान पर 2 महीने मुफ़्त पाएं। प्लान देखें
साइन इन करें मुफ़्त शुरू करें

प्रदर्शन समीक्षा

इनपुट
कोड
function add(a, b) { return a + b; }
नमूना आउटपुट 27 अक्तूबर 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.
इसे इस्तेमाल करें प्रदर्शन समीक्षा फ़ॉर्म इस नमूने के इनपुट से भरा खुलता है; जो चाहें बदलें।