flaska/benchmark/regexp_cve.mjs

20 lines
357 B
JavaScript
Raw Normal View History

import { printTime } from './utils.mjs'
var arg = "";
for (var i = 0; i < 1000000; i++) {
arg += "\\";
}
arg += "◎";
let s1 = process.hrtime.bigint()
let s2 = process.hrtime.bigint()
arg = arg.replace(/(?=\\*?)"/g, '$1$1\\"');
arg = arg.replace(/(?=\\*?)$/, '$1$1');
let s3 = process.hrtime.bigint()
let time = s3 - s2 - (s2 - s1)
printTime(time)