Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
path2d-vs-math-no-function-overhead
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (iPhone; CPU iPhone OS 16_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.3 Mobile/15E148 Safari/604.1
Browser:
Mobile Safari 16
Operating system:
iOS 16.3
Device Platform:
Mobile
Date tested:
2 years ago
Test name
Executions per second
path2d
1552307.1 Ops/sec
math
2341090.8 Ops/sec
Script Preparation code:
var boundingRect = { x: 10, y: 10, width: 100, height: 50 }; var x = 20; var y = 20; const canvas = document.createElement('canvas'); var ctx = canvas.getContext('2d'); var rectanglePath2D = new Path2D(); rectanglePath2D.rect(boundingRect.x, boundingRect.y, boundingRect.width, boundingRect.height); const maxX = boundingRect.x + boundingRect.width; const maxY = boundingRect.y + boundingRect.height; function calculateViaMath() { return (boundingRect.x <= x) && (x <= maxX) && (boundingRect.y <= y) && (x <= maxY) }
Tests:
path2d
ctx.isPointInPath(rectanglePath2D, x, y);
math
calculateViaMath()