Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
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
Benchmark engine:
Benchmark.js
math
597.4M/s
path2d
6.8M/s
View exact numbers
Test name
Executions per second
✓
math
597,365,952 Ops/sec
path2d
6,840,478 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()