Java compares IO and NIO file read/write performance tests, ionio

Source: Internet
Author: User

Java compares IO and NIO file read/write performance tests, ionio

Original article: test the file read/write performance of IO and NIO in java

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

1. NIO adopts a method closer to the operating system for IO execution: Channel and cache; as the name suggests, data from the data source is transmitted by the cache through the channel. 2. After JDK 5, NIO was used to optimize the underlying layer of the original IO system, which can be found in the source code published by sun. However, NIO is more systematic than IO. 3. I have studied the I/O source code and some sun source code. I think the performance bottleneck of the I/O system is mainly caused by the original I/O architecture. The original IO system uses the adapter mode, which seems to be a good idea at the beginning of JDK development. However, as the number of adapter nesting increases, IO usage is not only annoying, but also affects performance, because dynamic implementation must reduce performance. 4. In order to verify my ideas as accurately as possible, the code in the I/O section is also displayed and read and write with a buffer. 5. Local test: 50 m Files: 1031 ms for IO, 640 ms for NIO, 18900 ms for IO, and 13500 ms for NIO. Their time difference does not change dramatically due to changes in the file size, which means that the processing of data streams at the underlying layer, whether NIO or IO, should be similar, what causes IO performance constraints is the architecture of its original adapter model. Main Part of the Code: 1. IO system 2. NIO System



Related Article

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.