title: Java 8's streams: why parallel stream is slower?
body: <p>I am playing with Java 8's streams and cannot understand the performance results I am getting. I have 2 core CPU (Intel i73520M), Windows 8 x64, and 64-bit Java 8 update 5. I am doing simple map over stream/parallel stream of Strings and found that parallel version is somewhat slower.</p>
  
  <pre><code>Function&lt;Stream&lt;String&gt;, Long&gt; timeOperation = (Stream&lt;String&gt; stream) -&gt; {
    long time1 = System.nanoTime();
    final List&lt;String&gt; list = 
       stream
         .map(String::toLowerCase)
         .collect(Collectors.toList());
    long time2 = System.nanoTime();
    return time2 - time1;
  };
  
  Consumer&lt;Stream&lt;String&gt;&gt; printTime = stream -&gt;
    System.out.println(timeOperation.apply(stream) / 1000000f);
  
  String[] array = new String[1000000];
  Arrays.fill(array, "AbabagalamagA");
  
  printTime.accept(Arrays.stream(array));            // prints around 600
  printTime.accept(Arrays.stream(array).parallel()); // prints around 900
  </code></pre>
  
  <p>Shouldn't the parallel version be faster, considering the fact that I have 2 CPU cores?
  Could someone give me a hint why parallel version is slower?</p>