Last active
October 4, 2019 17:12
-
-
Save subtleGradient/97dc65290f1ce06a6eb4b2151d5a2557 to your computer and use it in GitHub Desktop.
git bisect script for checking if flow is slow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node --experimental-modules | |
/* eslint-disable no-console */ | |
import { execSync } from 'child_process'; | |
process.env.ROOT_VIEW_PATH = `src/common/components/views/RootView.js`; | |
const exec = script => { | |
console.log(`$ ${script}`); | |
execSync(script, { stdio: 'inherit' }); | |
}; | |
function timeToFunFlow() { | |
const startTime = Date.now(); | |
exec(`npm run flow`); | |
const endTime = Date.now(); | |
const timeItTook = endTime - startTime; | |
return timeItTook; | |
} | |
// execSync(`npm run flow -- stop`, { stdio: 'inherit' }); | |
const coldStart = timeToFunFlow(); | |
const noChanges = timeToFunFlow(); | |
exec(` | |
cat "$ROOT_VIEW_PATH" > "$ROOT_VIEW_PATH.bak" | |
echo '// IGNORE THIS' >> "$ROOT_VIEW_PATH" | |
`); | |
const afterChangingAFile = timeToFunFlow(); | |
exec(` | |
cat "$ROOT_VIEW_PATH.bak" > "$ROOT_VIEW_PATH" | |
rm "$ROOT_VIEW_PATH.bak" | |
`); | |
console.log(`Time it took to run flow:`, { | |
coldStart, | |
noChanges, | |
afterChangingAFile | |
}); | |
if (afterChangingAFile > 30000) { | |
throw new Error(`expected flow to be fast, but it wasn't`); | |
} |
Author
subtleGradient
commented
Oct 1, 2019
Only weird thing (so far!) about using the #!/usr/bin/env node --experimental-modules
trick is that __dirname
doesn't exist.
weird! But not weird enough to waste time figuring out why 🤷♂️
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment