File tree 5 files changed +45377
-3
lines changed
generate-reference-triangles
5 files changed +45377
-3
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,11 @@ add_executable(delaunator-test src/delaunator-test.cpp)
19
19
target_link_libraries (delaunator-test delaunator)
20
20
target_include_directories (delaunator-test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR} /includes/catch/single_include/catch2" )
21
21
target_link_libraries (delaunator-test json-helpers)
22
- target_link_libraries (delaunator-test delaunator)
22
+
23
+ #benchmark
24
+ add_executable (benchmark src/benchmark.cpp)
25
+ target_link_libraries (benchmark delaunator)
26
+ target_link_libraries (benchmark json-helpers)
23
27
24
28
25
29
#triangulate
Original file line number Diff line number Diff line change @@ -18,9 +18,13 @@ for(let i = 0; i < n; i++) {
18
18
coords [ 2 * i + 1 ] = f . geometry . coordinates [ 1 ] ;
19
19
}
20
20
21
- console . time ( 'Delaunator' ) ;
21
+ const start = Date . now ( ) ;
22
22
const delaunator = new Delaunator ( coords ) ;
23
- console . timeEnd ( 'Delaunator' ) ;
23
+ const end = Date . now ( ) ;
24
+
25
+ console . log ( 'points =' , coords . length / 2 ) ;
26
+ console . log ( 'miliseconds =' , end - start ) ;
27
+ console . log ( 'triangles =' , delaunator . triangles . length ) ;
24
28
25
29
const trianglesAr = Array . from ( delaunator . triangles ) ;
26
30
writeFileSync ( outputFile , JSON . stringify ( trianglesAr ) ) ;
Original file line number Diff line number Diff line change
1
+
2
+ #include < chrono>
3
+ #include " delaunator.h"
4
+ #include " json-helpers.h"
5
+ #include < string>
6
+ #include < vector>
7
+
8
+ using namespace std ;
9
+ int main (int , char * argv[]) {
10
+ string points_str = json_helpers::read_file (" ./test-files/osm-nodes-45331-epsg-3857.geojson" );
11
+ const vector<double > coords = json_helpers::get_geo_json_points (points_str);
12
+
13
+ auto t_start = chrono::high_resolution_clock::now ();
14
+ Delaunator delaunator (move (coords));
15
+ auto t_end = chrono::high_resolution_clock::now ();
16
+
17
+ auto milliseconds = chrono::duration_cast<chrono::milliseconds>(t_end - t_start).count ();
18
+
19
+ printf (" coords=%lu \n " , delaunator.coords .size () / 2 );
20
+ printf (" milliseconds=%lld \n " , milliseconds);
21
+ printf (" triangles=%lu \n " , delaunator.triangles .size ());
22
+
23
+ return 0 ;
24
+ }
You can’t perform that action at this time.
0 commit comments