File tree Expand file tree Collapse file tree 5 files changed +45377
-3
lines changed
generate-reference-triangles Expand file tree Collapse file tree 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)
1919target_link_libraries (delaunator-test delaunator)
2020target_include_directories (delaunator-test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR} /includes/catch/single_include/catch2" )
2121target_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)
2327
2428
2529#triangulate
Original file line number Diff line number Diff line change @@ -18,9 +18,13 @@ for(let i = 0; i < n; i++) {
1818 coords [ 2 * i + 1 ] = f . geometry . coordinates [ 1 ] ;
1919}
2020
21- console . time ( 'Delaunator' ) ;
21+ const start = Date . now ( ) ;
2222const 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 ) ;
2428
2529const trianglesAr = Array . from ( delaunator . triangles ) ;
2630writeFileSync ( 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