diff --git a/.gitignore b/.gitignore index 4e1ac05..73fded9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /.nyc_output/ /.vscode/ +/benchmark/ /coverage/ /node_modules/ *.code-workspace diff --git a/bench.md b/bench.md new file mode 100644 index 0000000..abc3bde --- /dev/null +++ b/bench.md @@ -0,0 +1,51 @@ +# Timing bench test results for `de9im` + + +The following presents the number of operations per second to process each pair of geometries with the given relation by each predicate. An :x: indicates the predicate is not supported for those geometries. The fastest and slowest times are highlighted. The geometries tested are in `test/data/bench`. + +| first | relation | second | contains | coveredby | covers | crosses | disjoint | equals | intersects | overlaps | touches | within | +|:-----:|:--------:|:------:|:--------:|:---------:|:------:|:-------:|:--------:|:------:|:----------:|:--------:|:-------:|:------:| +| LineString | contains | LineString | 40,508 | 487,988 | 38,849 | 43,810 | 42,511 | 413,982 | 42,612 | **14,114** | 28,210 | **540,358** | +| LineString | coveredby | LineString | 646,867 | 766,860 | 597,976 | 61,210 | 62,022 | 310,126 | 61,927 | 721,254 | **43,469** | **791,606** | +| LineString | covers | LineString | 48,402 | 296,429 | 49,018 | 82,147 | 76,816 | 266,185 | 77,052 | **15,789** | 45,229 | **304,383** | +| LineString | crosses | LineString | 404,126 | 440,290 | 398,034 | 13,570 | 13,915 | 396,974 | 13,924 | **8,946** | 74,964 | **452,693** | +| LineString | disjoint | LineString | **1,278,189** | 1,925,223 | 1,321,198 | 1,938,653 | 1,286,083 | 1,299,894 | 1,969,871 | 1,936,465 | **2,072,184** | 2,069,843 | +| LineString | equals | LineString | 618,727 | 742,615 | 591,802 | 57,942 | **56,583** | 315,849 | 57,075 | 721,960 | 74,860 | **750,655** | +| LineString | intersects | LineString | 268,505 | 463,071 | 288,509 | 39,595 | 39,116 | 402,966 | 39,762 | **11,051** | 31,347 | **465,359** | +| LineString | overlaps | LineString | 264,396 | **473,338** | 265,151 | 33,827 | 33,355 | 402,163 | 33,834 | **9,411** | 24,546 | 462,000 | +| LineString | touches | LineString | **411,768** | 368,144 | 406,243 | 47,796 | 51,137 | 328,068 | 51,897 | **37,437** | 43,663 | 375,962 | +| LineString | within | LineString | 409,332 | 39,791 | **429,027** | 44,984 | 44,389 | 35,153 | 45,146 | **22,638** | 30,459 | 29,500 | +| LineString | coveredby | Polygon | :x: | 38,457 | :x: | 33,982 | **12,458** | :x: | 12,598 | :x: | **47,829** | 37,009 | +| LineString | crosses | Polygon | :x: | 24,619 | :x: | 23,299 | 13,510 | :x: | **13,481** | :x: | 24,932 | **25,086** | +| LineString | disjoint | Polygon | :x: | 49,946 | :x: | 38,506 | 12,725 | :x: | **12,719** | :x: | 23,982 | **50,284** | +| LineString | intersects | Polygon | :x: | **31,787** | :x: | 26,147 | **12,300** | :x: | 12,364 | :x: | 29,995 | 31,678 | +| LineString | touches | Polygon | :x: | **26,746** | :x: | 26,385 | **11,110** | :x: | 11,182 | :x: | 22,588 | 26,208 | +| LineString | within | Polygon | :x: | 61,838 | :x: | 50,898 | **14,343** | :x: | 14,423 | :x: | **62,449** | 54,704 | +| MultiPoint | coveredby | LineString | :x: | 296,655 | :x: | **189,810** | 383,574 | :x: | **490,303** | :x: | 365,395 | 195,949 | +| MultiPoint | crosses | LineString | :x: | 359,225 | :x: | **252,247** | 377,416 | :x: | **490,517** | :x: | 480,475 | 374,225 | +| MultiPoint | disjoint | LineString | :x: | 1,231,746 | :x: | 1,167,109 | **684,859** | :x: | 1,192,336 | :x: | 1,204,576 | **1,262,230** | +| MultiPoint | intersects | LineString | :x: | **493,958** | :x: | 298,924 | 256,035 | :x: | 299,878 | :x: | **170,774** | 481,341 | +| MultiPoint | touches | LineString | :x: | **495,634** | :x: | 298,202 | 256,699 | :x: | 302,091 | :x: | **175,091** | 495,249 | +| MultiPoint | within | LineString | :x: | 372,159 | :x: | **243,269** | 364,380 | :x: | **475,414** | :x: | 457,090 | 247,628 | +| MultiPoint | contains | MultiPoint | 289,326 | 381,560 | 295,322 | :x: | 360,127 | **148,937** | **525,645** | 294,032 | :x: | 394,702 | +| MultiPoint | coveredby | MultiPoint | 324,641 | 408,709 | 330,124 | :x: | 384,098 | **158,152** | **493,331** | 268,989 | :x: | 360,113 | +| MultiPoint | covers | MultiPoint | 287,038 | 372,880 | 300,395 | :x: | 371,132 | **147,235** | **499,762** | 289,755 | :x: | 386,958 | +| MultiPoint | disjoint | MultiPoint | **512,593** | **930,489** | 549,623 | :x: | 533,732 | 545,503 | 913,509 | 875,686 | :x: | 867,496 | +| MultiPoint | equals | MultiPoint | 362,751 | 511,916 | 378,589 | :x: | 419,377 | **186,804** | **592,525** | 365,571 | :x: | 495,540 | +| MultiPoint | intersects | MultiPoint | 292,019 | **528,416** | 303,359 | :x: | 349,453 | 381,768 | 432,929 | **218,834** | :x: | 519,657 | +| MultiPoint | overlaps | MultiPoint | 358,145 | 511,472 | 398,748 | :x: | 319,427 | 370,396 | 434,374 | **249,845** | :x: | **513,808** | +| MultiPoint | within | MultiPoint | 296,326 | 377,680 | 309,198 | :x: | 375,782 | **148,931** | **514,972** | 311,582 | :x: | 380,341 | +| MultiPoint | coveredby | Polygon | :x: | 105,829 | :x: | **78,927** | 207,231 | :x: | **243,190** | :x: | 239,713 | 82,454 | +| MultiPoint | disjoint | Polygon | :x: | 227,010 | :x: | 107,224 | 101,411 | :x: | 106,761 | :x: | **56,319** | **240,364** | +| MultiPoint | intersects | Polygon | :x: | 227,354 | :x: | **78,098** | 133,757 | :x: | 143,600 | :x: | 115,932 | **241,511** | +| MultiPoint | touches | Polygon | :x: | 151,465 | :x: | 158,376 | 214,498 | :x: | **257,103** | :x: | 102,157 | **82,036** | +| MultiPoint | within | Polygon | :x: | 151,022 | :x: | 104,896 | 214,692 | :x: | **241,380** | :x: | 230,995 | **102,264** | +| Polygon | contains | Polygon | **310,536** | **163** | 283,102 | :x: | 36,472 | 169 | 37,217 | 173 | 169 | 170 | +| Polygon | coveredby | Polygon | 225,076 | 47 | **237,751** | :x: | 46 | 47 | 47 | **46** | 226,709 | 47 | +| Polygon | covers | Polygon | 172 | 306,807 | 171 | :x: | 30,689 | 286,405 | 31,324 | **109** | 294 | **307,343** | +| Polygon | disjoint | Polygon | **388,092** | 240,045 | 363,875 | :x: | **10,612** | 216,657 | 10,808 | 36,605 | 11,394 | 237,207 | +| Polygon | equals | Polygon | 128 | 129 | 129 | :x: | 29,850 | **67** | **32,278** | 132 | 123 | 127 | +| Polygon | intersects | Polygon | **368,234** | 90 | 367,599 | :x: | 10,069 | 91 | 10,083 | **59** | 239,505 | 90 | +| Polygon | overlaps | Polygon | **360,060** | 91 | 359,126 | :x: | 10,006 | 90 | 10,112 | **60** | 241,748 | 94 | +| Polygon | touches | Polygon | **375,011** | 378 | 366,380 | :x: | 32,376 | 375 | 32,417 | 374 | **362** | 374 | +| Polygon | within | Polygon | 224,471 | 48 | 230,489 | :x: | 47 | 48 | 48 | 47 | **238,366** | **47** | diff --git a/package-lock.json b/package-lock.json index e3823b5..629fa39 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,56 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@arrows/array": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/@arrows/array/-/array-1.4.1.tgz", + "integrity": "sha512-MGYS8xi3c4tTy1ivhrVntFvufoNzje0PchjEz6G/SsWRgUKxL4tKwS6iPdO8vsaJYldagAeWMd5KRD0aX3Q39g==", + "dev": true, + "requires": { + "@arrows/composition": "^1.2.2" + } + }, + "@arrows/composition": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@arrows/composition/-/composition-1.2.2.tgz", + "integrity": "sha512-9fh1yHwrx32lundiB3SlZ/VwuStPB4QakPsSLrGJFH6rCXvdrd060ivAZ7/2vlqPnEjBkPRRXOcG1YOu19p2GQ==", + "dev": true + }, + "@arrows/dispatch": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@arrows/dispatch/-/dispatch-1.0.3.tgz", + "integrity": "sha512-v/HwvrFonitYZM2PmBlAlCqVqxrkIIoiEuy5bQgn0BdfvlL0ooSBzcPzTMrtzY8eYktPyYcHg8fLbSgyybXEqw==", + "dev": true, + "requires": { + "@arrows/composition": "^1.2.2" + } + }, + "@arrows/error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@arrows/error/-/error-1.0.2.tgz", + "integrity": "sha512-yvkiv1ay4Z3+Z6oQsUkedsQm5aFdyPpkBUQs8vejazU/RmANABx6bMMcBPPHI4aW43VPQmXFfBzr/4FExwWTEA==", + "dev": true + }, + "@arrows/multimethod": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/@arrows/multimethod/-/multimethod-1.4.1.tgz", + "integrity": "sha512-AZnAay0dgPnCJxn3We5uKiB88VL+1ZIF2SjZohLj6vqY2UyvB/sKdDnFP+LZNVsTC5lcnGPmLlRRkAh4sXkXsQ==", + "dev": true, + "requires": { + "@arrows/array": "^1.4.1", + "@arrows/composition": "^1.2.2", + "@arrows/error": "^1.0.2", + "fast-deep-equal": "^3.1.3" + }, + "dependencies": { + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + } + } + }, "@babel/code-frame": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", @@ -1994,6 +2044,137 @@ "tweetnacl": "^0.14.3" } }, + "benchmark": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/benchmark/-/benchmark-2.1.4.tgz", + "integrity": "sha1-CfPeMckWQl1JjMLuVloOvzwqVik=", + "dev": true, + "requires": { + "lodash": "^4.17.4", + "platform": "^1.3.3" + } + }, + "benny": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/benny/-/benny-3.7.1.tgz", + "integrity": "sha512-USzYxODdVfOS7JuQq/L0naxB788dWCiUgUTxvN+WLPt/JfcDURNNj8kN/N+uK6PDvuR67/9/55cVKGPleFQINA==", + "dev": true, + "requires": { + "@arrows/composition": "^1.0.0", + "@arrows/dispatch": "^1.0.2", + "@arrows/multimethod": "^1.1.6", + "benchmark": "^2.1.4", + "common-tags": "^1.8.0", + "fs-extra": "^10.0.0", + "json2csv": "^5.0.6", + "kleur": "^4.1.4", + "log-update": "^4.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "astral-regex": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz", + "integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==", + "dev": true + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + }, + "log-update": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/log-update/-/log-update-4.0.0.tgz", + "integrity": "sha512-9fkkDevMefjg0mmzWFBW8YkFP91OrizzkW3diF7CpG+S2EYdy4+TVfGwz1zeF8x7hCx1ovSPTOE9Ngib74qqUg==", + "dev": true, + "requires": { + "ansi-escapes": "^4.3.0", + "cli-cursor": "^3.1.0", + "slice-ansi": "^4.0.0", + "wrap-ansi": "^6.2.0" + } + }, + "slice-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-4.0.0.tgz", + "integrity": "sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==", + "dev": true, + "requires": { + "ansi-styles": "^4.0.0", + "astral-regex": "^2.0.0", + "is-fullwidth-code-point": "^3.0.0" + } + }, + "string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + } + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.1" + } + }, + "wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "dev": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + } + } + } + }, "binary-extensions": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.0.0.tgz", @@ -2558,6 +2739,12 @@ "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==" }, + "common-tags": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.2.tgz", + "integrity": "sha512-gk/Z852D2Wtb//0I+kRFNKKE9dIIVirjoqPoA1wJU+XePVXZfGeBpk45+A1rKO4Q43prqWBNY/MiIeRLbPWUaA==", + "dev": true + }, "commondir": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", @@ -3625,6 +3812,25 @@ "integrity": "sha1-zyVVTKBQ3EmuZla0HeQiWJidy84=", "dev": true }, + "fs-extra": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.0.tgz", + "integrity": "sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "dependencies": { + "graceful-fs": { + "version": "4.2.9", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz", + "integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==", + "dev": true + } + } + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -3976,6 +4182,12 @@ "integrity": "sha1-Sl/W0nzDMvN+VBmlBNu4NxBckok=", "dev": true }, + "indento": { + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/indento/-/indento-1.1.13.tgz", + "integrity": "sha512-YZWk3mreBEM7sBPddsiQnW9Z8SGg/gNpFfscJq00HCDS7pxcQWWWMSVKJU7YkTRyDu1Zv2s8zaK8gQWKmCXHlg==", + "dev": true + }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -4799,6 +5011,34 @@ "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", "dev": true }, + "json2csv": { + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/json2csv/-/json2csv-5.0.6.tgz", + "integrity": "sha512-0/4Lv6IenJV0qj2oBdgPIAmFiKKnh8qh7bmLFJ+/ZZHLjSeiL3fKKGX3UryvKPbxFbhV+JcYo9KUC19GJ/Z/4A==", + "dev": true, + "requires": { + "commander": "^6.1.0", + "jsonparse": "^1.3.1", + "lodash.get": "^4.4.2" + }, + "dependencies": { + "commander": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz", + "integrity": "sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==", + "dev": true + } + } + }, + "json2md": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/json2md/-/json2md-1.12.0.tgz", + "integrity": "sha512-bpJpuqECzkndCa10aGPxeJNikmkDN7PAGXHvrBGTI4uey6QbTL5p0rkhk9lB3lKU4J7yGvkSmVBt8VhzUGu/fA==", + "dev": true, + "requires": { + "indento": "^1.1.13" + } + }, "json5": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.0.tgz", @@ -4816,12 +5056,28 @@ } } }, + "jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6", + "universalify": "^2.0.0" + } + }, "jsonify": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", "dev": true }, + "jsonparse": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", + "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", + "dev": true + }, "jsprim": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", @@ -4843,6 +5099,12 @@ "json-buffer": "3.0.0" } }, + "kleur": { + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.4.tgz", + "integrity": "sha512-8QADVssbrFjivHWQU7KkMgptGTl6WAcSdlbBPY4uNF+mWr6DGcKrvY2w4FQJoXch7+fKMjj0dRrL75vk3k23OA==", + "dev": true + }, "latest-version": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/latest-version/-/latest-version-5.1.0.tgz", @@ -5173,6 +5435,12 @@ "integrity": "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=", "dev": true }, + "lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", + "dev": true + }, "lodash.zip": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/lodash.zip/-/lodash.zip-4.2.0.tgz", @@ -6445,6 +6713,12 @@ } } }, + "platform": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/platform/-/platform-1.3.6.tgz", + "integrity": "sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==", + "dev": true + }, "pluralize": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-8.0.0.tgz", @@ -11518,6 +11792,12 @@ "@types/unist": "^2.0.2" } }, + "universalify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", + "dev": true + }, "update-notifier": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/update-notifier/-/update-notifier-4.0.0.tgz", diff --git a/package.json b/package.json index 817a162..b19a3d0 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,9 @@ "lint:md": "remark -q .", "prepare": "npm run build", "test": "run-s test:lint test:build", + "test:bench": "run-s test:bench:run test:bench:report", + "test:bench:run": "node ./test/bench.js", + "test:bench:report": "node ./test/report.js", "test:build": "nyc --reporter=lcov --reporter=text tap ./test/*.test.js", "test:lint": "eslint ./test/*.js" }, @@ -45,11 +48,13 @@ "geojson-rbush": "2.2.1" }, "devDependencies": { + "benny": "^3.7.1", "coveralls": "^3.0.4", "eslint": "^6.7.2", "eslint-config-google": "^0.14.0", "esm": "^3.2.25", "glob": "^7.1.4", + "json2md": "^1.12.0", "load-json-file": "^6.1.0", "np": "^6.0.0", "npm-run-all": "^4.1.5", diff --git a/readme.md b/readme.md index 11c43e9..ee7701b 100644 --- a/readme.md +++ b/readme.md @@ -203,6 +203,10 @@ npm install npm test ``` +## BENCHMARK + +Benchmark timing results can be found at [bench.md](bench.md). + ## LICENSE Copyright (c) 2019 Daniel Pulido diff --git a/test/bench.js b/test/bench.js new file mode 100644 index 0000000..8bb9422 --- /dev/null +++ b/test/bench.js @@ -0,0 +1,42 @@ +// Perform timing bench tests +const benny = require('benny'); +const de9im = require('../de9im'); +const glob = require('glob'); +const load = require('load-json-file'); +const pkg = require('../package'); +const path = require('path'); + +// Read all data in bench directory +const pattern = path.join(__dirname, 'data', 'bench', '**', '*.geojson'); +glob.sync(pattern).forEach((filepath) => { + cases = []; + + // Extract fixtures + const name = path.parse(filepath).name; + const geojson = load.sync(filepath); + const feature1 = geojson.features[0]; + const feature2 = geojson.features[1]; + const geometry1 = feature1.geometry.type; + const geometry2 = feature2.geometry.type; + const type = geometry1 + '-' + name + '-' + geometry2; + + // Test each predicate function + Object.keys(de9im).forEach((predicate) => { + try { + de9im[predicate](feature1, feature2); + cases.push(benny.add(predicate, () => { + de9im[predicate](feature1, feature2); + })); + } catch (error) { + console.log('Skipping (' + type + ') with predicate ' + predicate + + '. Not supported.'); + } + }); + + benny.suite( + type, + ...cases, + benny.cycle(), + benny.complete(), + benny.save({file: type, format: 'json', version: pkg.version})); +}); diff --git a/test/data/bench/LineString/LineString/contains.geojson b/test/data/bench/LineString/LineString/contains.geojson new file mode 100644 index 0000000..19a8872 --- /dev/null +++ b/test/data/bench/LineString/LineString/contains.geojson @@ -0,0 +1,47 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 0, + 0 + ], + [ + 2, + 2 + ], + [ + 4, + 0 + ], + [ + 6, + 2 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 2, + 2 + ], + [ + 4, + 0 + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/LineString/LineString/coveredby.geojson b/test/data/bench/LineString/LineString/coveredby.geojson new file mode 100644 index 0000000..3269336 --- /dev/null +++ b/test/data/bench/LineString/LineString/coveredby.geojson @@ -0,0 +1,47 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 0, + 0 + ], + [ + 1, + 0 + ], + [ + 2, + 0 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 0, + 0 + ], + [ + 1, + 0 + ], + [ + 2, + 0 + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/LineString/LineString/covers.geojson b/test/data/bench/LineString/LineString/covers.geojson new file mode 100644 index 0000000..f066109 --- /dev/null +++ b/test/data/bench/LineString/LineString/covers.geojson @@ -0,0 +1,47 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 0, + 0 + ], + [ + 2, + 2 + ], + [ + 4, + 0 + ], + [ + 6, + 2 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 0, + 0 + ], + [ + 2, + 2 + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/LineString/LineString/crosses.geojson b/test/data/bench/LineString/LineString/crosses.geojson new file mode 100644 index 0000000..61a5964 --- /dev/null +++ b/test/data/bench/LineString/LineString/crosses.geojson @@ -0,0 +1,55 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 0, + 0 + ], + [ + 1, + 1 + ], + [ + 2, + 2 + ], + [ + 4, + 0 + ], + [ + 6, + 2 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + -1, + 1 + ], + [ + 1, + 1 + ], + [ + 7, + 1 + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/LineString/LineString/disjoint.geojson b/test/data/bench/LineString/LineString/disjoint.geojson new file mode 100644 index 0000000..a825c88 --- /dev/null +++ b/test/data/bench/LineString/LineString/disjoint.geojson @@ -0,0 +1,47 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + -3, + 0 + ], + [ + -2, + 0 + ], + [ + -1, + 0 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 0, + 0 + ], + [ + 1, + 0 + ], + [ + 2, + 0 + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/LineString/LineString/equals.geojson b/test/data/bench/LineString/LineString/equals.geojson new file mode 100644 index 0000000..ddc2a31 --- /dev/null +++ b/test/data/bench/LineString/LineString/equals.geojson @@ -0,0 +1,55 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 0, + 0 + ], + [ + 2, + 2 + ], + [ + 4, + 0 + ], + [ + 6, + 2 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 0, + 0 + ], + [ + 2, + 2 + ], + [ + 4, + 0 + ], + [ + 6, + 2 + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/LineString/LineString/intersects.geojson b/test/data/bench/LineString/LineString/intersects.geojson new file mode 100644 index 0000000..fd698ca --- /dev/null +++ b/test/data/bench/LineString/LineString/intersects.geojson @@ -0,0 +1,47 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + -1, + 0 + ], + [ + 0, + 0 + ], + [ + 1, + 0 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 0, + 0 + ], + [ + 1, + 0 + ], + [ + 2, + 0 + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/LineString/LineString/overlaps.geojson b/test/data/bench/LineString/LineString/overlaps.geojson new file mode 100644 index 0000000..2f30dfd --- /dev/null +++ b/test/data/bench/LineString/LineString/overlaps.geojson @@ -0,0 +1,51 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + -2, + 0 + ], + [ + 0, + 0 + ], + [ + 2, + 2 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 0, + 0 + ], + [ + 2, + 2 + ], + [ + 4, + 0 + ], + [ + 6, + 2 + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/LineString/LineString/touches.geojson b/test/data/bench/LineString/LineString/touches.geojson new file mode 100644 index 0000000..a825eb4 --- /dev/null +++ b/test/data/bench/LineString/LineString/touches.geojson @@ -0,0 +1,47 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 6, + 2 + ], + [ + 7, + 2 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 0, + 0 + ], + [ + 2, + 2 + ], + [ + 4, + 0 + ], + [ + 6, + 2 + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/LineString/LineString/within.geojson b/test/data/bench/LineString/LineString/within.geojson new file mode 100644 index 0000000..6436f8d --- /dev/null +++ b/test/data/bench/LineString/LineString/within.geojson @@ -0,0 +1,47 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 2, + 2 + ], + [ + 4, + 0 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 0, + 0 + ], + [ + 2, + 2 + ], + [ + 4, + 0 + ], + [ + 6, + 2 + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/LineString/Polygon/coveredby.geojson b/test/data/bench/LineString/Polygon/coveredby.geojson new file mode 100644 index 0000000..88d1e2d --- /dev/null +++ b/test/data/bench/LineString/Polygon/coveredby.geojson @@ -0,0 +1,79 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 4, + 2 + ], + [ + 5, + 2 + ], + [ + 6, + 2 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 0, + 0 + ], + [ + 0, + 10 + ], + [ + 10, + 10 + ], + [ + 10, + 0 + ], + [ + 0, + 0 + ] + ], + [ + [ + 3, + 3 + ], + [ + 3, + 7 + ], + [ + 7, + 7 + ], + [ + 7, + 3 + ], + [ + 3, + 3 + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/LineString/Polygon/crosses.geojson b/test/data/bench/LineString/Polygon/crosses.geojson new file mode 100644 index 0000000..930834c --- /dev/null +++ b/test/data/bench/LineString/Polygon/crosses.geojson @@ -0,0 +1,61 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 0, + 0 + ], + [ + 2, + 2 + ], + [ + 4, + 0 + ], + [ + 6, + 2 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 0, + 0 + ], + [ + 0, + 1 + ], + [ + 1, + 1 + ], + [ + 1, + 0 + ], + [ + 0, + 0 + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/LineString/Polygon/disjoint.geojson b/test/data/bench/LineString/Polygon/disjoint.geojson new file mode 100644 index 0000000..94491fb --- /dev/null +++ b/test/data/bench/LineString/Polygon/disjoint.geojson @@ -0,0 +1,79 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 4, + 5 + ], + [ + 5, + 5 + ], + [ + 6, + 5 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 0, + 0 + ], + [ + 0, + 10 + ], + [ + 10, + 10 + ], + [ + 10, + 0 + ], + [ + 0, + 0 + ] + ], + [ + [ + 3, + 3 + ], + [ + 3, + 7 + ], + [ + 7, + 7 + ], + [ + 7, + 3 + ], + [ + 3, + 3 + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/LineString/Polygon/intersects.geojson b/test/data/bench/LineString/Polygon/intersects.geojson new file mode 100644 index 0000000..13c300b --- /dev/null +++ b/test/data/bench/LineString/Polygon/intersects.geojson @@ -0,0 +1,79 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 6, + 5 + ], + [ + 7, + 5 + ], + [ + 8, + 5 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 0, + 0 + ], + [ + 0, + 10 + ], + [ + 10, + 10 + ], + [ + 10, + 0 + ], + [ + 0, + 0 + ] + ], + [ + [ + 3, + 3 + ], + [ + 3, + 7 + ], + [ + 7, + 7 + ], + [ + 7, + 3 + ], + [ + 3, + 3 + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/LineString/Polygon/touches.geojson b/test/data/bench/LineString/Polygon/touches.geojson new file mode 100644 index 0000000..068a765 --- /dev/null +++ b/test/data/bench/LineString/Polygon/touches.geojson @@ -0,0 +1,83 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 0, + 0 + ], + [ + -1, + 0 + ], + [ + -1, + 10 + ], + [ + 0, + 10 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 0, + 0 + ], + [ + 0, + 10 + ], + [ + 10, + 10 + ], + [ + 10, + 0 + ], + [ + 0, + 0 + ] + ], + [ + [ + 3, + 3 + ], + [ + 3, + 7 + ], + [ + 7, + 7 + ], + [ + 7, + 3 + ], + [ + 3, + 3 + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/LineString/Polygon/within.geojson b/test/data/bench/LineString/Polygon/within.geojson new file mode 100644 index 0000000..4b6ba89 --- /dev/null +++ b/test/data/bench/LineString/Polygon/within.geojson @@ -0,0 +1,75 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 1, + 2 + ], + [ + 8, + 2 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 0, + 0 + ], + [ + 0, + 10 + ], + [ + 10, + 10 + ], + [ + 10, + 0 + ], + [ + 0, + 0 + ] + ], + [ + [ + 3, + 3 + ], + [ + 3, + 7 + ], + [ + 7, + 7 + ], + [ + 7, + 3 + ], + [ + 3, + 3 + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/MultiPoint/LineString/coveredby.geojson b/test/data/bench/MultiPoint/LineString/coveredby.geojson new file mode 100644 index 0000000..a3b70a6 --- /dev/null +++ b/test/data/bench/MultiPoint/LineString/coveredby.geojson @@ -0,0 +1,47 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + 0, + 0 + ], + [ + 1, + 0 + ], + [ + 2, + 0 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 0, + 0 + ], + [ + 1, + 0 + ], + [ + 2, + 0 + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/MultiPoint/LineString/crosses.geojson b/test/data/bench/MultiPoint/LineString/crosses.geojson new file mode 100644 index 0000000..4ed9687 --- /dev/null +++ b/test/data/bench/MultiPoint/LineString/crosses.geojson @@ -0,0 +1,51 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + 2, + 2 + ], + [ + 4, + 1 + ], + [ + 4, + 2 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 0, + 0 + ], + [ + 2, + 2 + ], + [ + 4, + 0 + ], + [ + 6, + 2 + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/MultiPoint/LineString/disjoint.geojson b/test/data/bench/MultiPoint/LineString/disjoint.geojson new file mode 100644 index 0000000..7948ac8 --- /dev/null +++ b/test/data/bench/MultiPoint/LineString/disjoint.geojson @@ -0,0 +1,47 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + -3, + 0 + ], + [ + -2, + 0 + ], + [ + -1, + 0 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 0, + 0 + ], + [ + 1, + 0 + ], + [ + 2, + 0 + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/MultiPoint/LineString/intersects.geojson b/test/data/bench/MultiPoint/LineString/intersects.geojson new file mode 100644 index 0000000..7f2d696 --- /dev/null +++ b/test/data/bench/MultiPoint/LineString/intersects.geojson @@ -0,0 +1,47 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + -2, + 0 + ], + [ + -1, + 0 + ], + [ + 0, + 0 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 0, + 0 + ], + [ + 1, + 0 + ], + [ + 2, + 0 + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/MultiPoint/LineString/touches.geojson b/test/data/bench/MultiPoint/LineString/touches.geojson new file mode 100644 index 0000000..7f2d696 --- /dev/null +++ b/test/data/bench/MultiPoint/LineString/touches.geojson @@ -0,0 +1,47 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + -2, + 0 + ], + [ + -1, + 0 + ], + [ + 0, + 0 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 0, + 0 + ], + [ + 1, + 0 + ], + [ + 2, + 0 + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/MultiPoint/LineString/within.geojson b/test/data/bench/MultiPoint/LineString/within.geojson new file mode 100644 index 0000000..3849aaa --- /dev/null +++ b/test/data/bench/MultiPoint/LineString/within.geojson @@ -0,0 +1,55 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + 2, + 2 + ], + [ + 8, + 0 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 0, + 0 + ], + [ + 2, + 2 + ], + [ + 4, + 0 + ], + [ + 6, + 2 + ], + [ + 8, + 0 + ], + [ + 10, + 2 + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/MultiPoint/MultiPoint/contains.geojson b/test/data/bench/MultiPoint/MultiPoint/contains.geojson new file mode 100644 index 0000000..1c99b9f --- /dev/null +++ b/test/data/bench/MultiPoint/MultiPoint/contains.geojson @@ -0,0 +1,47 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + 0, + 0 + ], + [ + 1, + 0 + ], + [ + 2, + 0 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + 0, + 0 + ], + [ + 1, + 0 + ], + [ + 2, + 0 + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/MultiPoint/MultiPoint/coveredby.geojson b/test/data/bench/MultiPoint/MultiPoint/coveredby.geojson new file mode 100644 index 0000000..18e0441 --- /dev/null +++ b/test/data/bench/MultiPoint/MultiPoint/coveredby.geojson @@ -0,0 +1,47 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + 2, + 0 + ], + [ + 0, + 0 + ], + [ + 1, + 0 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + 0, + 0 + ], + [ + 1, + 0 + ], + [ + 2, + 0 + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/MultiPoint/MultiPoint/covers.geojson b/test/data/bench/MultiPoint/MultiPoint/covers.geojson new file mode 100644 index 0000000..6a9bffd --- /dev/null +++ b/test/data/bench/MultiPoint/MultiPoint/covers.geojson @@ -0,0 +1,47 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + 0, + 0 + ], + [ + 1, + 0 + ], + [ + 2, + 0 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + 2, + 0 + ], + [ + 0, + 0 + ], + [ + 1, + 0 + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/MultiPoint/MultiPoint/disjoint.geojson b/test/data/bench/MultiPoint/MultiPoint/disjoint.geojson new file mode 100644 index 0000000..c1d7fc0 --- /dev/null +++ b/test/data/bench/MultiPoint/MultiPoint/disjoint.geojson @@ -0,0 +1,47 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + -3, + 0 + ], + [ + -2, + 0 + ], + [ + -1, + 0 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + 0, + 0 + ], + [ + 1, + 0 + ], + [ + 2, + 0 + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/MultiPoint/MultiPoint/equals.geojson b/test/data/bench/MultiPoint/MultiPoint/equals.geojson new file mode 100644 index 0000000..0f9afb8 --- /dev/null +++ b/test/data/bench/MultiPoint/MultiPoint/equals.geojson @@ -0,0 +1,39 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + 1, + 0 + ], + [ + 0, + 0 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + 0, + 0 + ], + [ + 1, + 0 + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/MultiPoint/MultiPoint/intersects.geojson b/test/data/bench/MultiPoint/MultiPoint/intersects.geojson new file mode 100644 index 0000000..a8ba003 --- /dev/null +++ b/test/data/bench/MultiPoint/MultiPoint/intersects.geojson @@ -0,0 +1,47 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + -1, + 0 + ], + [ + 0, + 0 + ], + [ + 1, + 0 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + 0, + 0 + ], + [ + 1, + 0 + ], + [ + 2, + 0 + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/MultiPoint/MultiPoint/overlaps.geojson b/test/data/bench/MultiPoint/MultiPoint/overlaps.geojson new file mode 100644 index 0000000..b694089 --- /dev/null +++ b/test/data/bench/MultiPoint/MultiPoint/overlaps.geojson @@ -0,0 +1,47 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + -1, + -1 + ], + [ + 0, + 0 + ], + [ + 1, + 1 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + -1, + 1 + ], + [ + 0, + 0 + ], + [ + 1, + -1 + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/MultiPoint/MultiPoint/within.geojson b/test/data/bench/MultiPoint/MultiPoint/within.geojson new file mode 100644 index 0000000..18e0441 --- /dev/null +++ b/test/data/bench/MultiPoint/MultiPoint/within.geojson @@ -0,0 +1,47 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + 2, + 0 + ], + [ + 0, + 0 + ], + [ + 1, + 0 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + 0, + 0 + ], + [ + 1, + 0 + ], + [ + 2, + 0 + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/MultiPoint/Polygon/coveredby.geojson b/test/data/bench/MultiPoint/Polygon/coveredby.geojson new file mode 100644 index 0000000..5f248d3 --- /dev/null +++ b/test/data/bench/MultiPoint/Polygon/coveredby.geojson @@ -0,0 +1,79 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + 4, + 2 + ], + [ + 5, + 2 + ], + [ + 6, + 2 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 0, + 0 + ], + [ + 0, + 10 + ], + [ + 10, + 10 + ], + [ + 10, + 0 + ], + [ + 0, + 0 + ] + ], + [ + [ + 3, + 3 + ], + [ + 3, + 7 + ], + [ + 7, + 7 + ], + [ + 7, + 3 + ], + [ + 3, + 3 + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/MultiPoint/Polygon/disjoint.geojson b/test/data/bench/MultiPoint/Polygon/disjoint.geojson new file mode 100644 index 0000000..e7c24d5 --- /dev/null +++ b/test/data/bench/MultiPoint/Polygon/disjoint.geojson @@ -0,0 +1,79 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + 4, + 5 + ], + [ + 5, + 5 + ], + [ + 6, + 5 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 0, + 0 + ], + [ + 0, + 10 + ], + [ + 10, + 10 + ], + [ + 10, + 0 + ], + [ + 0, + 0 + ] + ], + [ + [ + 3, + 3 + ], + [ + 3, + 7 + ], + [ + 7, + 7 + ], + [ + 7, + 3 + ], + [ + 3, + 3 + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/MultiPoint/Polygon/intersects.geojson b/test/data/bench/MultiPoint/Polygon/intersects.geojson new file mode 100644 index 0000000..42d4118 --- /dev/null +++ b/test/data/bench/MultiPoint/Polygon/intersects.geojson @@ -0,0 +1,79 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + 6, + 5 + ], + [ + 7, + 5 + ], + [ + 8, + 5 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 0, + 0 + ], + [ + 0, + 10 + ], + [ + 10, + 10 + ], + [ + 10, + 0 + ], + [ + 0, + 0 + ] + ], + [ + [ + 3, + 3 + ], + [ + 3, + 7 + ], + [ + 7, + 7 + ], + [ + 7, + 3 + ], + [ + 3, + 3 + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/MultiPoint/Polygon/touches.geojson b/test/data/bench/MultiPoint/Polygon/touches.geojson new file mode 100644 index 0000000..74d0647 --- /dev/null +++ b/test/data/bench/MultiPoint/Polygon/touches.geojson @@ -0,0 +1,75 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + 3, + 3 + ], + [ + 7, + 7 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 0, + 0 + ], + [ + 0, + 10 + ], + [ + 10, + 10 + ], + [ + 10, + 0 + ], + [ + 0, + 0 + ] + ], + [ + [ + 3, + 3 + ], + [ + 3, + 7 + ], + [ + 7, + 7 + ], + [ + 7, + 3 + ], + [ + 3, + 3 + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/MultiPoint/Polygon/within.geojson b/test/data/bench/MultiPoint/Polygon/within.geojson new file mode 100644 index 0000000..cfef3b4 --- /dev/null +++ b/test/data/bench/MultiPoint/Polygon/within.geojson @@ -0,0 +1,75 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 0, + 0 + ], + [ + 0, + 10 + ], + [ + 10, + 10 + ], + [ + 10, + 0 + ], + [ + 0, + 0 + ] + ], + [ + [ + 3, + 3 + ], + [ + 3, + 7 + ], + [ + 7, + 7 + ], + [ + 7, + 3 + ], + [ + 3, + 3 + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/Polygon/Polygon/contains.geojson b/test/data/bench/Polygon/Polygon/contains.geojson new file mode 100644 index 0000000..3f46f34 --- /dev/null +++ b/test/data/bench/Polygon/Polygon/contains.geojson @@ -0,0 +1,89 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 0, + 0 + ], + [ + 3, + 0 + ], + [ + 3, + 3 + ], + [ + 0, + 3 + ], + [ + 0, + 0 + ] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 0, + 0 + ], + [ + 0, + 10 + ], + [ + 10, + 10 + ], + [ + 10, + 0 + ], + [ + 0, + 0 + ] + ], + [ + [ + 3, + 3 + ], + [ + 3, + 7 + ], + [ + 7, + 7 + ], + [ + 7, + 3 + ], + [ + 3, + 3 + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/Polygon/Polygon/coveredby.geojson b/test/data/bench/Polygon/Polygon/coveredby.geojson new file mode 100644 index 0000000..57d8d95 --- /dev/null +++ b/test/data/bench/Polygon/Polygon/coveredby.geojson @@ -0,0 +1,111 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 1, + 1 + ], + [ + 1, + 9 + ], + [ + 9, + 9 + ], + [ + 9, + 1 + ], + [ + 1, + 1 + ] + ], + [ + [ + 2, + 2 + ], + [ + 8, + 2 + ], + [ + 8, + 8 + ], + [ + 2, + 8 + ], + [ + 2, + 2 + ] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 0, + 0 + ], + [ + 0, + 10 + ], + [ + 10, + 10 + ], + [ + 10, + 0 + ], + [ + 0, + 0 + ] + ], + [ + [ + 3, + 3 + ], + [ + 3, + 7 + ], + [ + 7, + 7 + ], + [ + 7, + 3 + ], + [ + 3, + 3 + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/Polygon/Polygon/covers.geojson b/test/data/bench/Polygon/Polygon/covers.geojson new file mode 100644 index 0000000..9c857f0 --- /dev/null +++ b/test/data/bench/Polygon/Polygon/covers.geojson @@ -0,0 +1,89 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 0, + 0 + ], + [ + 0, + 10 + ], + [ + 10, + 10 + ], + [ + 10, + 0 + ], + [ + 0, + 0 + ] + ], + [ + [ + 3, + 3 + ], + [ + 3, + 7 + ], + [ + 7, + 7 + ], + [ + 7, + 3 + ], + [ + 3, + 3 + ] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 0, + 0 + ], + [ + 3, + 0 + ], + [ + 3, + 3 + ], + [ + 0, + 3 + ], + [ + 0, + 0 + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/Polygon/Polygon/disjoint.geojson b/test/data/bench/Polygon/Polygon/disjoint.geojson new file mode 100644 index 0000000..a5d6477 --- /dev/null +++ b/test/data/bench/Polygon/Polygon/disjoint.geojson @@ -0,0 +1,89 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 4, + 4 + ], + [ + 6, + 4 + ], + [ + 6, + 6 + ], + [ + 4, + 6 + ], + [ + 4, + 4 + ] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 0, + 0 + ], + [ + 0, + 10 + ], + [ + 10, + 10 + ], + [ + 10, + 0 + ], + [ + 0, + 0 + ] + ], + [ + [ + 3, + 3 + ], + [ + 3, + 7 + ], + [ + 7, + 7 + ], + [ + 7, + 3 + ], + [ + 3, + 3 + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/Polygon/Polygon/equals.geojson b/test/data/bench/Polygon/Polygon/equals.geojson new file mode 100644 index 0000000..6482b7e --- /dev/null +++ b/test/data/bench/Polygon/Polygon/equals.geojson @@ -0,0 +1,111 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 0, + 0 + ], + [ + 0, + 10 + ], + [ + 10, + 10 + ], + [ + 10, + 0 + ], + [ + 0, + 0 + ] + ], + [ + [ + 3, + 3 + ], + [ + 7, + 3 + ], + [ + 7, + 7 + ], + [ + 3, + 7 + ], + [ + 3, + 3 + ] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 0, + 0 + ], + [ + 0, + 10 + ], + [ + 10, + 10 + ], + [ + 10, + 0 + ], + [ + 0, + 0 + ] + ], + [ + [ + 3, + 3 + ], + [ + 3, + 7 + ], + [ + 7, + 7 + ], + [ + 7, + 3 + ], + [ + 3, + 3 + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/Polygon/Polygon/intersects.geojson b/test/data/bench/Polygon/Polygon/intersects.geojson new file mode 100644 index 0000000..cafce62 --- /dev/null +++ b/test/data/bench/Polygon/Polygon/intersects.geojson @@ -0,0 +1,89 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 1, + 4 + ], + [ + 9, + 4 + ], + [ + 9, + 5 + ], + [ + 1, + 5 + ], + [ + 1, + 4 + ] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 0, + 0 + ], + [ + 0, + 10 + ], + [ + 10, + 10 + ], + [ + 10, + 0 + ], + [ + 0, + 0 + ] + ], + [ + [ + 3, + 3 + ], + [ + 3, + 7 + ], + [ + 7, + 7 + ], + [ + 7, + 3 + ], + [ + 3, + 3 + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/Polygon/Polygon/overlaps.geojson b/test/data/bench/Polygon/Polygon/overlaps.geojson new file mode 100644 index 0000000..cafce62 --- /dev/null +++ b/test/data/bench/Polygon/Polygon/overlaps.geojson @@ -0,0 +1,89 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 1, + 4 + ], + [ + 9, + 4 + ], + [ + 9, + 5 + ], + [ + 1, + 5 + ], + [ + 1, + 4 + ] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 0, + 0 + ], + [ + 0, + 10 + ], + [ + 10, + 10 + ], + [ + 10, + 0 + ], + [ + 0, + 0 + ] + ], + [ + [ + 3, + 3 + ], + [ + 3, + 7 + ], + [ + 7, + 7 + ], + [ + 7, + 3 + ], + [ + 3, + 3 + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/Polygon/Polygon/touches.geojson b/test/data/bench/Polygon/Polygon/touches.geojson new file mode 100644 index 0000000..f4ae78b --- /dev/null +++ b/test/data/bench/Polygon/Polygon/touches.geojson @@ -0,0 +1,89 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 3, + 3 + ], + [ + 7, + 3 + ], + [ + 7, + 7 + ], + [ + 3, + 7 + ], + [ + 3, + 3 + ] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 0, + 0 + ], + [ + 0, + 10 + ], + [ + 10, + 10 + ], + [ + 10, + 0 + ], + [ + 0, + 0 + ] + ], + [ + [ + 3, + 3 + ], + [ + 3, + 7 + ], + [ + 7, + 7 + ], + [ + 7, + 3 + ], + [ + 3, + 3 + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/bench/Polygon/Polygon/within.geojson b/test/data/bench/Polygon/Polygon/within.geojson new file mode 100644 index 0000000..57d8d95 --- /dev/null +++ b/test/data/bench/Polygon/Polygon/within.geojson @@ -0,0 +1,111 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 1, + 1 + ], + [ + 1, + 9 + ], + [ + 9, + 9 + ], + [ + 9, + 1 + ], + [ + 1, + 1 + ] + ], + [ + [ + 2, + 2 + ], + [ + 8, + 2 + ], + [ + 8, + 8 + ], + [ + 2, + 8 + ], + [ + 2, + 2 + ] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 0, + 0 + ], + [ + 0, + 10 + ], + [ + 10, + 10 + ], + [ + 10, + 0 + ], + [ + 0, + 0 + ] + ], + [ + [ + 3, + 3 + ], + [ + 3, + 7 + ], + [ + 7, + 7 + ], + [ + 7, + 3 + ], + [ + 3, + 3 + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/report.js b/test/report.js new file mode 100644 index 0000000..6049f31 --- /dev/null +++ b/test/report.js @@ -0,0 +1,87 @@ +// Generate report of timing bench tests +const de9im = require('../de9im'); +const fs = require('fs'); +const glob = require('glob'); +const json2md = require('json2md'); +const load = require('load-json-file'); +const pkg = require('../package'); +const path = require('path'); + +// Create report introduction +const title = 'Timing bench test results for `' + pkg.name + '`'; +const introduction = 'The following presents the number of operations per ' + + 'second to process each pair of geometries with the ' + + 'given relation by each predicate. An :x: indicates the ' + + 'predicate is not supported for those geometries. The ' + + 'fastest and slowest times are highlighted. The ' + + 'geometries tested are in `test/data/bench`.'; + +// Create report table +const predicates = Object.keys(de9im); +const headers = ['first', 'relation', 'second'].concat(predicates); + +// Read all data in bench directory and create report rows +const rows = []; +const pattern = path.join(__dirname, '..', 'benchmark', 'results', '*.json'); +glob.sync(pattern).forEach((filepath) => { + // Extract 'name' and 'ops' for each result + const json = load.sync(filepath); + const [first, relation, second] = json.name.split('-'); + const type = {'first': first, 'relation': relation, 'second': second}; + const results = json.results.map((result) => { + return [result.name, parseInt(result.ops).toLocaleString()]; + }); + const row = Object.fromEntries(results); + predicates.forEach((predicate) => { + if (predicate in row) { + return; + } + row[predicate] = ':x:'; + }); + + // Highlight fastest and slowest 'ops'. + const fastest = json.fastest.name; + const slowest = json.slowest.name; + row[fastest] = '**' + row[fastest] + '**'; + row[slowest] = '**' + row[slowest] + '**'; + rows.push({...type, ...row}); +}); + +// Sort entries by geometries then predicates. +let sorter = rows.map((row, index) => { + return [row['first'], row['second'], row['relation']].join('-'); +}); +sorter = sorter.sort().map((value, index) => { + return [value, index]; +}); +sorter = Object.fromEntries(sorter); +rows.sort((a, b) => { + const keya = [a['first'], a['second'], a['relation']].join('-'); + const keyb = [b['first'], b['second'], b['relation']].join('-'); + return sorter[keya] - sorter[keyb]; +}); + +// Create report data +const data = [ + { + 'h1': title, + }, + { + 'p': introduction, + }, + { + 'table': { + 'headers': headers, + 'rows': rows, + }, + }, +]; + +// Generate report and center columns +let report = json2md(data); +report = report.replace(/\| \-/g, '|:-'); +report = report.replace(/\- \|/g, '-:|'); + +// Export to file. +filename = path.join(__dirname, '..', 'bench.md'); +fs.writeFileSync(filename, report);