Skip to content

Instantly share code, notes, and snippets.

@peterbe
Created April 16, 2021 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterbe/318bab87834580c384b763da08919d25 to your computer and use it in GitHub Desktop.
Save peterbe/318bab87834580c384b763da08919d25 to your computer and use it in GitHub Desktop.
const { Document } = require("./content");
function f1(options) {
let count = 0;
for (const filePath of Document.findAll0(options).iter({ pathOnly: true })) {
count += 1;
}
return count;
}
function f2(options) {
let count = 0;
for (const filePath of Document.findAll(options).iter({ pathOnly: true })) {
count += 1;
}
return count;
}
const allOptions = [];
allOptions.push({});
allOptions.push({
folderSearch: "web/html/element/a",
});
allOptions.push({
locales: new Map([["fr", true]]),
});
allOptions.push({
files: new Set([
"/Users/peterbe/dev/MOZILLA/MDN/content/files/en-us/glossary/argument/index.html",
"en-us/webassembly/text_format_to_wasm/index.html",
]),
});
for (const options of allOptions) {
console.log("OPTIONS:", options);
console.time("findAll ");
var r1 = f1(options);
console.timeEnd("findAll ");
console.time("findAll2");
var r2 = f2(options);
console.timeEnd("findAll2");
console.assert(r1 === r2);
console.log("");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment