Performance Analysis: Pythagoras vs Scanning
Click on the canvas to change point positions (Shift+Click for point B)
Method
Distance (px)
Execution Time (ms)
With Pythagoras (Math.hypot) ≈
-
-
Without Pythagoras (Canvas Scan) ≈
-
-
Pythagoras:
RAM (Coordinates)
↓
CPU (Math.hypot)
↓
Number (px)
Scanning:
CPU (Command)
↓
GPU (Drawing)
↓
VRAM ➔ Bus ➔ RAM (Latency!)
↓
CPU (Loop Search)
↓
Number (px)