Java vs. io and NiO file read/write performance testing

Source: Internet
Author: User

Original: Java vs. io and NiO file read/write performance test

Source code: Http://www.zuidaima.com/share/1550463508466688.htm

1. NIO uses a way closer to the operating system to execute IO: Channels and buffers, as the name implies, data source data is transmitted by the buffer through the channel. 2. After JDK5, the raw IO system was optimized for NIO at the bottom, which can be found through Sun's published source code, but NIO is more systematic than IO. 3. In a little study of IO source code and some sun source code, I think the performance bottleneck of IO system is mainly due to the original IO architecture factors. The original IO system uses adapter mode, which seems like a good idea at the beginning of the JDK development, but as the adapter is nested more and more, the use of IO is annoying and can affect performance, because the dynamic implementation is definitely going to degrade performance. 4. In order to be able to verify my ideas as accurately as possible, the code in the IO section is also displayed with buffers for reading and writing. 5. Local test: 50M file: Io time 1031ms,nio time consuming 640ms;500m file: Io time 18900ms,nio time consuming 13500ms. Their time difference does not vary drastically due to file size changes, which means that both NIO and IO should be similar in the underlying processing stream, resulting in IO performance constraints on the schema of its original adapter model. Trunk Part code: 1.IO System 2.NIO System



Java vs. io and NiO file read/write performance testing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.