jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
Two methods to determine if line segments intersect (assuming lines are coincident):
1) rotate parallel with x-axis and use x-coords to determine. 2) translate to origin and use magnitudes to determine.
<script>
function rangesIntersect(low1, high1, low2, high2) {
return low1 <= high2 && low2 <= high1
}
function ccw(x1, y1, x2, y2, x3, y3) {
return (y3 - y1) * (x2 - x1) > (y2 - y1) * (x3 - x1)
}
function mag(x, y) {
return Math.sqrt(x * x + y * y);
}
var seg1 = {
x1: 0,
y1: 0,
x2: 1,
y2: 1
};
var seg2 = {
x1: 1,
y1: 1,
x2: 2,
y2: 2
};
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Rotation |
| ready |
Translate + Mag |
| ready |
Switch Translate + Mag |
| ready |
CCW |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.