Sunday, November 9, 2014

Java 8 ‘Stream’ Performance Test

 

I have been recently testing out new features in JDK8. I think one of the most interesting feature which is available other than Lamda is Stream (java-doc). In summery it gives you a good way to do functional style of programming on Java collection, also it has something extra, it allows you to run operations in serial or parallel which in return allows developers to easily code parallel programming without needing to worry about complex programming logic.

I wanted to test the Stream performance for that I’m going to use a simple loop counter (source-code)

1) Normal (Serial)

2) Synchronized Object reference (Parallel)

3) Synchronised Array reference (Parallel)

4) Atomic (Serial)

5) Atomic (Parallel)

6) Stream (Serial)

7) Stream (Parallel)

8) If the Developer puts in the effort

Following is the results when running it from my laptop

image

As you can clearly see, a good developer can right a fast code, but its a game between Simplicity vs Performance.

2 comments:

  1. Here is one faster implementation: http://landawn.com/download.html with performance test result: http://landawn.com/stream_performance_test_result.txt

    ReplyDelete
  2. Glad to know that important information about that OEE Software , it is very useful about that. So thanks a lot for giving that useful topic.

    ReplyDelete