Sequential vs Parallel

Med
Code
Loading editor...
Tap Analyze to see visualization
Variables

Run code to see variables

Output

Console output will appear here

Press Space to start to step? all shortcuts

Solution Guide: Sequential vs Parallel

Approach

Compare two async patterns: sequential execution using a for loop with await (each request waits for the previous one), and parallel execution using Promise.all with map (all requests fire simultaneously). This demonstrates the performance difference between serial and concurrent I/O.

Complexity Analysis

Time
O(n)
Space
O(n)

Pattern

Sequential vs Parallel Async

Why It Works

Promise.all fires all promises concurrently and waits for all to settle, taking only as long as the slowest request. Sequential await adds up all individual wait times, making it slower for independent operations.

Updated Feb 2026