31 lines
728 B
JavaScript
31 lines
728 B
JavaScript
import { createRouter, insertItem } from '@mapl/router'
|
|
import { compileRouter } from './mapl_compiler.mjs'
|
|
import { printTime } from './utils.mjs'
|
|
import * as consts from './const.js'
|
|
|
|
let testPaths = consts.allManyRoutes // consts.allManyRoutes
|
|
|
|
/*testPaths = [
|
|
'/api/works/:id/lock',
|
|
'/api/staff/:id',
|
|
// '/::rest',
|
|
]*/
|
|
|
|
testPaths = testPaths.map(x => x.replace(/::[^\/]+/g, '**').replace(/:[^\/]+/g, '*'))
|
|
|
|
const r = createRouter();
|
|
for (let route of testPaths) {
|
|
let cleaned = route.replace(/:[^\/]+/g, '*')
|
|
insertItem(r, cleaned, () => { })
|
|
}
|
|
|
|
let s1 = process.hrtime.bigint()
|
|
let s2 = process.hrtime.bigint()
|
|
|
|
compileRouter(r);
|
|
|
|
let s3 = process.hrtime.bigint()
|
|
|
|
let time = s3 - s2 - (s2 - s1)
|
|
|
|
printTime(time)
|