BufferedInputStream 은 과연 효율적일까 #8
kangbada0728
started this conversation in
General
Replies: 2 comments 3 replies
-
|
시간만 본게 문제네요. |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
7.4M 파일 복사 기준 다음 결과를 얻었습니다.
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
오늘 스터디에서 나왔던 주제에 대해 토론해보자.
입출력 시 중간에 버퍼를 두어야 하는 이유는 입출력시 데이터 이동속도 차이가 발생하는 문제를 해결하기 위해서 이다.
처음 우리의 가정은 FileInputStream 의 read 에서 직접 buffer 를 지정하는 것 보다, 이미 구현된 객체인 BufferedInputStream 의 read 를 사용하는 것이 더 빠를 것이다 이었다.
하지만 아래 코드를 직접 돌려보았을때 FileInputStream 의 read 에서 직접 buffer 를 지정하는 것이 더 빠른 속도를 보여주었다.
BufferedInputStream 내부를 보았을때 buffer 의 크기가 512 보다 훨씬 큰 8192 이었는데도 그랬다.
반대로 BufferedInputStream 의 read 에서 직접 buffer 를 지정해보니 그냥 read 만 사용한 것보다 더 빠른 속도를 보여주었다.
왜 이런 결과가 나오게 된 것일까?
- FileInputStream 의 read 에서 직접 buffer 를 지정
Beta Was this translation helpful? Give feedback.
All reactions