Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
SiarheiFedartsou committed Oct 23, 2024
1 parent bac4f12 commit 99b3e8f
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 7 deletions.
42 changes: 42 additions & 0 deletions benchmark.js
Original file line number Diff line number Diff line change
@@ -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();
14 changes: 7 additions & 7 deletions src/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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})
Expand All @@ -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})
Expand All @@ -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})
Expand All @@ -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})
Expand All @@ -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})
Expand All @@ -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})
Expand Down

0 comments on commit 99b3e8f

Please sign in to comment.