MCPcopy Create free account
hub / github.com/Project-OSRM/osrm-backend / run_query

Function run_query

scripts/osrm-runner.js:15–36  ·  view source on GitHub ↗
(query_options, filters, callback)

Source from the content-addressed store, hash-verified

13
14// Execute HTTP query against OSRM server and measure response times
15const run_query = (query_options, filters, callback) => {
16 let tic = () => 0.;
17 http.request(query_options, (res) => {
18 let body = '';
19 const ttfb = tic();
20
21 res.setEncoding('utf8');
22 res.on('data', (chunk) => {
23 body += chunk;
24 });
25 res.on('end', () => {
26 const elapsed = tic();
27 const json = JSON.parse(body);
28 Promise.all(filters.map(filter => JSONPath({path: filter, json: json})))
29 .then(values => callback(query_options.path, res.statusCode, ttfb, elapsed, values));
30 });
31 }).on('socket', (/*res*/) => {
32 tic = ((toc) => { return () => { const t = process.hrtime(toc); return t[0] * 1000 + t[1] / 1000000; }; })(process.hrtime());
33 }).on('error', (res) => {
34 callback(query_options.path, res.code);
35 }).end();
36};
37
38// Generate random coordinate points within a polygon boundary for route testing
39function generate_points(polygon, number, coordinates_number, max_distance) {

Callers 1

osrm-runner.jsFile · 0.85

Calls 2

ticFunction · 0.85
endMethod · 0.45

Tested by

no test coverage detected