FriendShip 애플리케이션에서 S3에 클라이언트에서 압축한 이미지 파일을 업로드할 때 업로드 방식을 Stream 을 기존에 사용하고 있었습니다.
기존의 Stream 을 통한 업로드 방식과 향상된 For문, Parallel Stream 을 사용한 방식을 비교하여, 더 빠르게 구현할 수 있는 방법을 모색합니다. 더불어 현재 방식에서 Parallel Stream을 통한 업로드를 하지 않는 이유에 대해 기술합니다.
<aside> 💡 목차
</aside>
S3에 업로드할 파일들은 임시로 생성한 png 파일로, 적은 용량을 갖고 있습니다.
똑같은 파일 크기와 같은 그림을 갖고 있지만 이름만 다른 경우로, 각 테스트에서 2개씩 업로드할 예정이기에 6개를 준비해줍니다.
@Test
@DisplayName("stream 적용")
void streamTest() {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
List<String> twoFilePath = List.of("a.png","b.png");
List<String> results = twoFilePath.stream().map(s -> s3FileUploader.upload(s)).toList();
stopWatch.stop();
System.out.println( stopWatch.prettyPrint());
}