MCPcopy Index your code
hub / github.com/nodejs/node / bakeUrlData

Function bakeUrlData

benchmark/common.js:400–429  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

398 * @returns {string[] | string[][] | URL[]}
399 */
400function 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
431module.exports = {
432 Benchmark,

Callers

nothing calls this directly

Calls 4

getUrlDataFunction · 0.85
fillMethod · 0.80
concatMethod · 0.80
mapMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…