* Generate an array of data for URL benchmarks to use. * The size of the resulting data set is the original data size * 2 ** `e`. * The 'wpt' type contains about 400 data points when `withBase` is true, * and 200 data points when `withBase` is false. * Other types contain 200 data points with or
(type, e = 0, withBase = false, asUrl = false)
| 398 | * @returns {string[] | string[][] | URL[]} |
| 399 | */ |
| 400 | function bakeUrlData(type, e = 0, withBase = false, asUrl = false) { |
| 401 | let result = []; |
| 402 | if (type === 'wpt') { |
| 403 | result = getUrlData(withBase); |
| 404 | } else if (urls[type]) { |
| 405 | const input = urls[type]; |
| 406 | const item = withBase ? [input, 'about:blank'] : input; |
| 407 | // Roughly the size of WPT URL test data |
| 408 | result = new Array(200).fill(item); |
| 409 | } else { |
| 410 | throw new Error(`Unknown url data type ${type}`); |
| 411 | } |
| 412 | |
| 413 | if (typeof e !== 'number') { |
| 414 | throw new Error(`e must be a number, received ${e}`); |
| 415 | } |
| 416 | |
| 417 | for (let i = 0; i < e; ++i) { |
| 418 | result = result.concat(result); |
| 419 | } |
| 420 | |
| 421 | if (asUrl) { |
| 422 | if (withBase) { |
| 423 | result = result.map(([input, base]) => new URL(input, base)); |
| 424 | } else { |
| 425 | result = result.map((input) => new URL(input)); |
| 426 | } |
| 427 | } |
| 428 | return result; |
| 429 | } |
| 430 | |
| 431 | module.exports = { |
| 432 | Benchmark, |
nothing calls this directly
no test coverage detected
searching dependent graphs…