wip
This commit is contained in:
		
							parent
							
								
									bac4f12c77
								
							
						
					
					
						commit
						99b3e8fc87
					
				
							
								
								
									
										42
									
								
								benchmark.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								benchmark.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,42 @@ | ||||
| var OSRM = require('.'); | ||||
| var monaco_mld_path = require('./test/nodejs/constants').mld_data_path; | ||||
| var two_test_coordinates = require('./test/nodejs/constants').two_test_coordinates; | ||||
| const { performance } = require('perf_hooks'); | ||||
| 
 | ||||
| const osrm = new OSRM({path: monaco_mld_path, algorithm: 'MLD'}); | ||||
| 
 | ||||
| const numberOfRoutes = 10; | ||||
| let completedRoutes = 0; | ||||
| let totalTime = 0; | ||||
| 
 | ||||
| function benchmarkRoutes() { | ||||
|     const startTime = performance.now(); | ||||
| 
 | ||||
|     for (let i = 0; i < numberOfRoutes; i++) { | ||||
| 
 | ||||
|         const options = { | ||||
|             coordinates: [two_test_coordinates[0], two_test_coordinates[1]], | ||||
|             annotations: ['distance'] | ||||
|         }; | ||||
| 
 | ||||
|         for (let i = 0; i < 1000; ++i) { | ||||
|             options.coordinates.push(two_test_coordinates[i % 2], two_test_coordinates[(i + 1) % 2]); | ||||
|         } | ||||
| 
 | ||||
|         osrm.table(options, function(err, route) { | ||||
|             if (err) { | ||||
|                 console.error(err); | ||||
|                 return; | ||||
|             } | ||||
|             completedRoutes++; | ||||
|             if (completedRoutes === numberOfRoutes) { | ||||
|                 const endTime = performance.now(); | ||||
|                 totalTime = endTime - startTime; | ||||
|                 console.log(`Total time for ${numberOfRoutes} routes: ${totalTime}ms`); | ||||
|                 console.log(`Average time per route: ${totalTime / numberOfRoutes}ms`); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| benchmarkRoutes(); | ||||
| @ -13,7 +13,7 @@ target_include_directories(rtree-bench | ||||
| 	${PROJECT_SOURCE_DIR}/unit_tests) | ||||
| 
 | ||||
| target_link_libraries(rtree-bench | ||||
| 	${BOOST_LIBRARIES} | ||||
| 	${BOOST_BASE_LIBRARIES} | ||||
| 	${CMAKE_THREAD_LIBS_INIT} | ||||
| 	${TBB_LIBRARIES} | ||||
| 	${MAYBE_SHAPEFILE}) | ||||
| @ -26,7 +26,7 @@ add_executable(match-bench | ||||
| 
 | ||||
| target_link_libraries(match-bench | ||||
| 	osrm | ||||
| 	${BOOST_LIBRARIES} | ||||
| 	${BOOST_BASE_LIBRARIES} | ||||
| 	${CMAKE_THREAD_LIBS_INIT} | ||||
| 	${TBB_LIBRARIES} | ||||
| 	${MAYBE_SHAPEFILE}) | ||||
| @ -39,7 +39,7 @@ add_executable(route-bench | ||||
| 
 | ||||
| target_link_libraries(route-bench | ||||
| 	osrm | ||||
| 	${BOOST_LIBRARIES} | ||||
| 	${BOOST_BASE_LIBRARIES} | ||||
| 	${CMAKE_THREAD_LIBS_INIT} | ||||
| 	${TBB_LIBRARIES} | ||||
| 	${MAYBE_SHAPEFILE}) | ||||
| @ -51,7 +51,7 @@ add_executable(bench | ||||
| 
 | ||||
| target_link_libraries(bench | ||||
| 	osrm | ||||
| 	${BOOST_LIBRARIES} | ||||
| 	${BOOST_BASE_LIBRARIES} | ||||
| 	${CMAKE_THREAD_LIBS_INIT} | ||||
| 	${TBB_LIBRARIES} | ||||
| 	${MAYBE_SHAPEFILE}) | ||||
| @ -63,7 +63,7 @@ add_executable(json-render-bench | ||||
| 
 | ||||
| target_link_libraries(json-render-bench | ||||
| 	osrm | ||||
| 	${BOOST_LIBRARIES} | ||||
| 	${BOOST_BASE_LIBRARIES} | ||||
| 	${CMAKE_THREAD_LIBS_INIT} | ||||
| 	${TBB_LIBRARIES} | ||||
| 	${MAYBE_SHAPEFILE}) | ||||
| @ -74,7 +74,7 @@ add_executable(alias-bench | ||||
| 	$<TARGET_OBJECTS:UTIL>) | ||||
| 
 | ||||
| target_link_libraries(alias-bench | ||||
| 	${BOOST_LIBRARIES} | ||||
| 	${BOOST_BASE_LIBRARIES} | ||||
| 	${CMAKE_THREAD_LIBS_INIT} | ||||
| 	${TBB_LIBRARIES} | ||||
| 	${MAYBE_SHAPEFILE}) | ||||
| @ -87,7 +87,7 @@ add_executable(packedvector-bench | ||||
| 	$<TARGET_OBJECTS:UTIL>) | ||||
| 
 | ||||
| target_link_libraries(packedvector-bench | ||||
| 	${BOOST_LIBRARIES} | ||||
| 	${BOOST_BASE_LIBRARIES} | ||||
| 	${CMAKE_THREAD_LIBS_INIT} | ||||
| 	${TBB_LIBRARIES} | ||||
|     ${MAYBE_SHAPEFILE}) | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user