-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add timing tests #5
Comments
That would be great. I am reading the README and I am wondering, which method to pick when more than one would likely solve my problem. A benchmark could help with this decision. Update: I was curious about this and googled how to do this in a simple way. Here are my results. Would love to hear if this approach is usable (see "Full code").
Full code …const area = {
type: "FeatureCollection",
features: [
{
type: "Feature",
properties: {},
geometry: {
type: "Polygon",
coordinates: [
[
[13.587512969970701, 52.3013410761489],
[13.619956970214844, 52.3013410761489],
[13.619956970214844, 52.31141727938367],
[13.587512969970701, 52.31141727938367],
[13.587512969970701, 52.3013410761489],
],
],
},
},
],
}
const lineFullyWithinArea = {
type: "FeatureCollection",
features: [
{
type: "Feature",
properties: {},
geometry: {
type: "LineString",
coordinates: [
[13.594036102294922, 52.30595962063293],
[13.613433837890625, 52.30784888634275],
],
},
},
],
}
const lineInAndOutOfArea = {
type: "Feature",
properties: {},
geometry: {
type: "LineString",
coordinates: [
[13.5955810546875, 52.30889844356715],
[13.5955810546875, 52.313935971877584],
],
},
}
import de9im from "de9im"
const test = (consoleLine, callFunction) => {
const start = Date.now()
let runs = 10000
while (runs) {
callFunction()
runs--
}
console.log("Finished `" + consoleLine + "` " + (Date.now() - start) + " ms.")
}
test("de9im.contains(area, lineFullyWithinArea))", () =>
de9im.contains(area, lineFullyWithinArea))
test("de9im.contains(area, lineInAndOutOfArea))", () =>
de9im.contains(area, lineInAndOutOfArea))
test("de9im.coveredby(lineFullyWithinArea, area))", () =>
de9im.coveredby(lineFullyWithinArea, area))
test("de9im.coveredby(lineInAndOutOfArea, area))", () =>
de9im.coveredby(lineInAndOutOfArea, area))
test("de9im.crosses(area, lineFullyWithinArea))", () =>
de9im.crosses(area, lineFullyWithinArea))
test("de9im.crosses(area, lineInAndOutOfArea))", () =>
de9im.crosses(area, lineInAndOutOfArea))
test("de9im.intersects(area, lineFullyWithinArea))", () =>
de9im.intersects(area, lineFullyWithinArea))
test("de9im.intersects(area, lineInAndOutOfArea))", () =>
de9im.intersects(area, lineInAndOutOfArea))
test("de9im.within(lineFullyWithinArea, area))", () =>
de9im.within(lineFullyWithinArea, area))
test("de9im.within(lineInAndOutOfArea, area))", () =>
de9im.within(lineInAndOutOfArea, area)) What is interesting is, that in my usecase #44 it looks like it would be faster to first check everything with |
I'll look into integrating a bench performance library into the test suite. Generally, using |
Closed with 52cf6ec. |
@tordans FYI. Based on the benchmark results it seems like you're better off just running |
Add timing benchmark tests.
The text was updated successfully, but these errors were encountered: