SlideShare a Scribd company logo
1 of 9
Merge & Reverse
국민대학교 컴퓨터공학부
20113336 채한울
기존 코드 성능측정 결과
총 5회 측정 결과
1회 : 75.82s
2회 : 68.40s
3회 : 70.03s
4회 : 73.14s
5회 : 75.81s
평균 : 72.64s
개선된 코드 성능측정 결과
총 5회 측정 결과
1회 : 11.45s
2회 : 11.18s
3회 : 10.93s
4회 : 10.75s
5회 : 12.03s
평균 : 11.27s
성능측정 결과 비교
기존 코드보다 평균 약 6.45배 빨라졌다.
성능 = Improved / Origin
= 0.16
개선1. String Reverse & Save Function
각 file의 line 별로 한번씩
‘reverse와 동시에 새로운 배열에 저장’한다.
개선2. open() & read() & write() 사용
기존 file I/O 함수들(fopen, fgetc, fputc)을
open() & read() & write() 함수들로 바꾼다.
Heap 영역에 filesize 만큼의 배열을 할당하고 각 file을 ‘한번의
system call’만을 하여 읽는다.
마찬가지로 결과값도 filesize*2만큼의 배열을 할당하여 ‘한번의
system call’만을 하여 쓴다.
개선3. Multithreading
한 line을 reverse하고 배열에 저장하는 과정을
Multithreading을 쉽게 하는 OpenMP사용하여
‘Multithreading’ 한다.
실패한 시도 1
현재의 코드는 각 라인을 reverse 할 때 2개의 thread로 나눠서 실행한다.
HW가 4개의 core를 가지고 있으므로 4개의 thread로 나눠서 실행해 봤지만
각 line의 길이가 짧아 multithread로 얻는 이득보다 overhead가 더 커졌다.
평균 20.59s로 약 1.9배 느리다.
감사합니다

More Related Content

Viewers also liked

Eva rc module 1_activity_swot
Eva rc  module 1_activity_swotEva rc  module 1_activity_swot
Eva rc module 1_activity_swotEva R
 
Module 2 kwl laura vilar
Module 2 kwl laura vilarModule 2 kwl laura vilar
Module 2 kwl laura vilarLaura Vilar
 
最新子持川に架かる橋の名称探索散歩画像入
最新子持川に架かる橋の名称探索散歩画像入最新子持川に架かる橋の名称探索散歩画像入
最新子持川に架かる橋の名称探索散歩画像入徹 長谷川
 
Los reyes católicos
Los reyes católicosLos reyes católicos
Los reyes católicosTeresa Pérez
 
Tema6. Arquitectura Gótica.
Tema6. Arquitectura Gótica. Tema6. Arquitectura Gótica.
Tema6. Arquitectura Gótica. @evasociales
 
Tema 9. Los reinos cristianos
Tema 9. Los reinos cristianosTema 9. Los reinos cristianos
Tema 9. Los reinos cristianoscopybird
 

Viewers also liked (11)

Imperialismo y colonialismo
Imperialismo y colonialismoImperialismo y colonialismo
Imperialismo y colonialismo
 
WCF And ASMX Web Services
WCF And ASMX Web ServicesWCF And ASMX Web Services
WCF And ASMX Web Services
 
Eva rc module 1_activity_swot
Eva rc  module 1_activity_swotEva rc  module 1_activity_swot
Eva rc module 1_activity_swot
 
Module 2 kwl laura vilar
Module 2 kwl laura vilarModule 2 kwl laura vilar
Module 2 kwl laura vilar
 
Cooperative learning
Cooperative learningCooperative learning
Cooperative learning
 
最新子持川に架かる橋の名称探索散歩画像入
最新子持川に架かる橋の名称探索散歩画像入最新子持川に架かる橋の名称探索散歩画像入
最新子持川に架かる橋の名称探索散歩画像入
 
WCF
WCFWCF
WCF
 
Los reyes católicos
Los reyes católicosLos reyes católicos
Los reyes católicos
 
VP 13 TWESSENCIAL
VP 13 TWESSENCIALVP 13 TWESSENCIAL
VP 13 TWESSENCIAL
 
Tema6. Arquitectura Gótica.
Tema6. Arquitectura Gótica. Tema6. Arquitectura Gótica.
Tema6. Arquitectura Gótica.
 
Tema 9. Los reinos cristianos
Tema 9. Los reinos cristianosTema 9. Los reinos cristianos
Tema 9. Los reinos cristianos
 

File reverse & merge

  • 1. Merge & Reverse 국민대학교 컴퓨터공학부 20113336 채한울
  • 2. 기존 코드 성능측정 결과 총 5회 측정 결과 1회 : 75.82s 2회 : 68.40s 3회 : 70.03s 4회 : 73.14s 5회 : 75.81s 평균 : 72.64s
  • 3. 개선된 코드 성능측정 결과 총 5회 측정 결과 1회 : 11.45s 2회 : 11.18s 3회 : 10.93s 4회 : 10.75s 5회 : 12.03s 평균 : 11.27s
  • 4. 성능측정 결과 비교 기존 코드보다 평균 약 6.45배 빨라졌다. 성능 = Improved / Origin = 0.16
  • 5. 개선1. String Reverse & Save Function 각 file의 line 별로 한번씩 ‘reverse와 동시에 새로운 배열에 저장’한다.
  • 6. 개선2. open() & read() & write() 사용 기존 file I/O 함수들(fopen, fgetc, fputc)을 open() & read() & write() 함수들로 바꾼다. Heap 영역에 filesize 만큼의 배열을 할당하고 각 file을 ‘한번의 system call’만을 하여 읽는다. 마찬가지로 결과값도 filesize*2만큼의 배열을 할당하여 ‘한번의 system call’만을 하여 쓴다.
  • 7. 개선3. Multithreading 한 line을 reverse하고 배열에 저장하는 과정을 Multithreading을 쉽게 하는 OpenMP사용하여 ‘Multithreading’ 한다.
  • 8. 실패한 시도 1 현재의 코드는 각 라인을 reverse 할 때 2개의 thread로 나눠서 실행한다. HW가 4개의 core를 가지고 있으므로 4개의 thread로 나눠서 실행해 봤지만 각 line의 길이가 짧아 multithread로 얻는 이득보다 overhead가 더 커졌다. 평균 20.59s로 약 1.9배 느리다.