Created
July 16, 2013 19:09
-
-
Save ox/6011663 to your computer and use it in GitHub Desktop.
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
var kb = 10 | |
var range = 1024 * kb | |
var paragraph = 'Vegan cornhole semiotics keffiyeh direct trade. Before they sold out fanny pack Carles scenester, keffiyeh High Life Austin flannel 8-bit. Fashion axe scenester Neutra, bicycle rights ethnic aesthetic sustainable letterpress. Pop-up mlkshk Schlitz meh Marfa kitsch pork belly, selvage street art. Dreamcatcher messenger bag Godard, viral ethnic keytar fanny pack post-ironic. Hashtag forage flexitarian hoodie DIY, banh mi shoreditch squid. Selvage master cleanse tote bag, trust fund fingerstache Odd Future you probably havent heard of them street art banjo single-origin coffee Bushwick.' | |
var paragraphLength = paragraph.length | |
var buffer = new Buffer(range * paragraphLength) | |
var string = "" | |
var time = +new Date | |
for (var i = 0; i < range; i++) { | |
buffer.write(paragraph, i * paragraphLength, paragraphLength, 'utf-8x') | |
} | |
console.log('buffer:', (+new Date) - time) | |
time = +new Date | |
for (var i = 0; i < range; i++) { | |
string = string + paragraph | |
} | |
console.log('string:', (+new Date) - time) | |
/** | |
* output (ms): | |
* buffer: 24 | |
* string: 3 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment