Created
May 22, 2015 16:53
-
-
Save shaohua/e183a596e8d12db7c508 to your computer and use it in GitHub Desktop.
Generate random size js
This file contains hidden or 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 | |
| /* | |
| https://gist.github.com/stangah/04e7ce784ab64beb9919 | |
| Call from command line to create files of various sizes: | |
| node fileCreatorThingy.js 1 10 100 200 300 | |
| */ | |
| var fs = require('fs'); | |
| var argv = require('yargs').argv; | |
| var createFileOfSize = function(kb) { | |
| var line = new Array(1020); | |
| for(var i=0; i<line.length; i++) { | |
| line[i] = 0; | |
| } | |
| line = '/*' + line.join('') + '*/'; | |
| var sizedChunk = ''; | |
| for(var i = kb ; i > 0; i--) { | |
| sizedChunk += line + '\n'; | |
| } | |
| fs.writeFile(kb + 'k.js', sizedChunk); | |
| }; | |
| argv._.forEach(function(size) { | |
| createFileOfSize(size); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment