UNPKG

minotor

Version:

A lightweight client-side transit routing library.

106 lines (105 loc) 5.57 kB
import { Query, RangeQuery, Router, StopsIndex } from '../router.js'; type PerformanceResult = { label: string; meanTimeUs: number; meanMemoryMb: number; }; /** * Loads a list of routing queries from a JSON file and resolves the * human-readable stop IDs to the internal numeric IDs used by the router. * * Only entries that do **not** carry a `lastDepartureTime` field are loaded — * range-query entries are silently skipped. * * @param filePath - Path to the JSON file containing the serialized queries. * @param stopsIndex - The stops index used to resolve source stop IDs to the * internal numeric IDs expected by the router. * @returns An array of fully constructed {@link Query} objects ready to be * passed to {@link Router.route}. * @throws If the file cannot be read, the JSON is malformed, or any stop ID * referenced in the file cannot be found in the stops index. */ export declare const loadQueriesFromJson: (filePath: string, stopsIndex: StopsIndex) => Query[]; /** * Loads a list of range routing queries from a JSON file and resolves the * human-readable stop IDs to the internal numeric IDs used by the router. * * Only entries that carry a `lastDepartureTime` field are loaded — plain * point-query entries are silently skipped. * * @param filePath - Path to the JSON file containing the serialized queries. * @param stopsIndex - The stops index used to resolve source stop IDs to the * internal numeric IDs expected by the router. * @returns An array of fully constructed {@link RangeQuery} objects ready to * be passed to {@link Router.rangeRoute}. * @throws If the file cannot be read, the JSON is malformed, or any stop ID * referenced in the file cannot be found in the stops index. */ export declare const loadRangeQueriesFromJson: (filePath: string, stopsIndex: StopsIndex) => RangeQuery[]; /** * Benchmarks {@link Router.route} across a set of queries. * * @param router - The router instance to benchmark. * @param tasks - The list of queries to run. One {@link PerformanceResult} is * produced per query. * @param iterations - Number of times each query is repeated. Higher values * yield a more stable mean at the cost of longer wall-clock time. * @param stopsIndex - Used to resolve stop names for result labels. * @returns An array of {@link PerformanceResult} objects, one per query, each * containing the mean wall-clock time (µs) and mean heap delta (MB). */ export declare const testRouterPerformance: (router: Router, tasks: Query[], iterations: number, stopsIndex: StopsIndex) => PerformanceResult[]; /** * Benchmarks {@link Result.bestRoute} — the path-reconstruction phase — * independently of the routing phase. * * @param router - The router instance used to produce the routing results that * are then fed into `bestRoute`. * @param tasks - The list of queries to benchmark. One {@link PerformanceResult} * is produced per query. * @param iterations - Number of times `bestRoute` is called per query. * @param stopsIndex - Used to resolve stop names for result labels. * @returns An array of {@link PerformanceResult} objects, one per query, each * containing the mean wall-clock time (µs) and mean heap delta (MB) for the * `bestRoute` call alone. */ export declare const testBestRoutePerformance: (router: Router, tasks: Query[], iterations: number, stopsIndex: StopsIndex) => PerformanceResult[]; /** * Benchmarks {@link Router.rangeRoute} across a set of range queries. * * @param router - The router instance to benchmark. * @param tasks - The list of range queries to run. One {@link PerformanceResult} * is produced per query. * @param iterations - Number of times each query is repeated. * @param stopsIndex - Used to resolve stop names for result labels. * @returns An array of {@link PerformanceResult} objects, one per query, each * containing the mean wall-clock time (µs) and mean heap delta (MB). */ export declare const testRangeRouterPerformance: (router: Router, tasks: RangeQuery[], iterations: number, stopsIndex: StopsIndex) => PerformanceResult[]; /** * Benchmarks {@link RangeResult.getRoutes} — the full Pareto-frontier * reconstruction phase — independently of the range routing phase. * * @param router - The router instance used to produce the range results that * are then fed into `getRoutes`. * @param tasks - The list of range queries to benchmark. One * {@link PerformanceResult} is produced per query. * @param iterations - Number of times `getRoutes` is called per query. * @param stopsIndex - Used to resolve stop names for result labels. * @returns An array of {@link PerformanceResult} objects, one per query, each * containing the mean wall-clock time (µs) and mean heap delta (MB) for the * `getRoutes` call alone. */ export declare const testRangeResultPerformance: (router: Router, tasks: RangeQuery[], iterations: number, stopsIndex: StopsIndex) => PerformanceResult[]; /** * Prints a table summary of performance results to stdout. * * Each row corresponds to one task, identified by a human-readable query label * (origin → destination + departure time). A footer row shows the mean across * all tasks. An optional `label` is printed as a section header above the table. * * @param results - The performance results to display. * @param label - Heading printed above the table. Defaults to `'Performance Results'`. */ export declare const prettyPrintPerformanceResults: (results: PerformanceResult[], label?: string) => void; export {};