Jeanne Boyarsky wrote:Helene,
You really want to create one larger stream and start measuring time after it is created. Also, testing with a lambda that doesn't print will show you a different scenario.
I think this might be more along the lines of the proof you're looking for, Helene. Also note that I removed the IO operation as Jeanne suggested; even with a single System.out.print("") statement in each of the lambdas, the run times increased dramatically (see my comments for the actual numbers).
I think it's fun to look at the performance on these different streams given their operations (with and without IO) and their sizes. For one million records without IO, processing the serial stream was much faster. However, one hundred million records without IO were processed much faster in parallel than they were in a serial manner. Your mileage will vary of course, but I found this to be an interesting baseline for serial/parallel streaming. I hope this helps!