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 (Macintosh; Intel Mac OS X 10.15; rv:136.0) Gecko/20100101 Firefox/136.0
Browser:
Firefox 136
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
path2d
20260446.0 Ops/sec
math
260959120.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'); 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()