title: fastest way to split a text file at spaces in Javascript
body: <p>I'm looking at doing some text processing in the browser and am trying to get a <em>rough</em> idea of whether I am going to be CPU bound or I/O bound.  To test the speed on the CPU side of the equation, I am seeing how quickly I can split a piece of text (~8.9MB - it's Project Gutenberg's <em>Sherlock Holmes</em> repeated a number of times over) in Javascript once it is in memory.  At the moment I'm simply doing:</p>
  
  <pre><code>pieces = theText.split(" ");
  </code></pre>
  
  <p>and executing it 100 times and taking the average.  On a 2011 Macbook Pro i5, the average split in Firefox takes 92.81ms and in Chrome 237.27ms.  So 1000/92.81ms * 8.9MB = 95.8MBps on the CPU, which is probably a little faster than the harddisk I/O, but not by much.</p>
  
  <p>So my question is really three parts:</p>
  
  <ul>
  <li>Are there Javascript alternatives to <code>split()</code> that tend to be faster when doing simple text processing (e.g. splitting at spaces, newlines, etc. etc.)?</li>
  <li>Are the lackluster CPU results I'm seeing here likely due to fundamental string matching/algorithmic constraints, or is the Javascript execution just slow?  </li>
  <li>If you think Javascript is likely the limiting factor, can you demonstrate substantially better performance on a comparable machine/comparable text in any other programming language?</li>
  </ul>
  
  <p>Edit: I also suspect this could be sped up with WebWorkers, though for now am primarily interested in single-threaded approaches.</p>