Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
path2d-vs-math
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Android 14; Mobile; rv:123.0) Gecko/123.0 Firefox/123.0
Browser:
Firefox Mobile 123
Operating system:
Android
Device Platform:
Mobile
Date tested:
2 years ago
Test name
Executions per second
path2d
6840478.0 Ops/sec
math
597365952.0 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'); const ctx = canvas.getContext('2d'); const rectanglePath2D = new Path2D(); rectanglePath2D.rect(boundingRect.x, boundingRect.y, boundingRect.width, boundingRect.height); function calculateViaPath2d() { return ctx.isPointInPath(rectanglePath2D, x, y); } 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
calculateViaPath2d()
math
calculateViaMath()