From f9a645c60fb87d07cea33c0e208d2090d64a545f Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Tue, 10 Sep 2019 22:11:01 -0700 Subject: [PATCH] Start analyzing more .wal files --- .../maki-interpreter/tools/extract-functions.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/modern/src/maki-interpreter/tools/extract-functions.js b/modern/src/maki-interpreter/tools/extract-functions.js index 559ea6a2..8434cdc8 100755 --- a/modern/src/maki-interpreter/tools/extract-functions.js +++ b/modern/src/maki-interpreter/tools/extract-functions.js @@ -36,7 +36,7 @@ async function getCallCountsFromWal(absolutePath) { const buffers = await Promise.all( files.map(file => file.async("nodebuffer")) ); - return buffers.map(getCallCountsFromMaki).reduce(sumCountObjects); + return buffers.map(getCallCountsFromMaki).reduce(sumCountObjects, {}); } function getCallCountsFromMaki(buffer) { @@ -70,7 +70,18 @@ function setObjectValuesToOne(obj) { async function main(parentDir) { const paths = await findWals(parentDir); - const callCounts = await Promise.all(paths.map(getCallCountsFromWal)); + const callCounts = await Promise.all( + // This script runs out of memory, so we'll limit skins until we + // improve the script to be less dumb. + paths.slice(0, 500).map(async walPath => { + try { + return await getCallCountsFromWal(walPath); + } catch (e) { + // TODO: Investigate these. + return {}; + } + }) + ); const totalCalls = callCounts.reduce(sumCountObjects); const foundInSkins = callCounts .map(setObjectValuesToOne) @@ -80,4 +91,4 @@ async function main(parentDir) { console.log(JSON.stringify(result, null, 2)); } -main(path.join(__dirname, "../../../skins/")); +main("/Volumes/Mobile Backup/skins/skins/");