2012년 7월 21일 토요일

[WPF] 이미지 로딩 속도 체크 테스트

ㆍ언어대상 : WPF   ㆍ실행대상 : WPF   ㆍ작성자 : 홍석인  

특수 조건
 => 화면에 보여지는 이미지 파일을 삭제 하고자 할 경우 : BitmapCacheOption.OnLoad 값으로 설정 해야 삭제 가능( 로드 시 전체 이미지를 메모리로 캐시합니다.이미지 데이터에 대한 모든 요청은 메모리 저장소에서 채워집니다.)

// Image Option 1 : 35 msec
public void Test1()
{
Stopwatch sw = new Stopwatch(); sw.Start();

BitmapImage img = new BitmapImage(new Uri(@"d:/a.jpg"));
this.xImage.Source = img;

sw.Stop();
System.Diagnostics.Debug.WriteLine("Test1 : " + sw.Elapsed.TotalMilliseconds + " msec");
}

// Image Option 2 : 1125 msec
public void Test2()
{
Stopwatch sw = new Stopwatch(); sw.Start();

BitmapImage img = new BitmapImage();
img.BeginInit();
img.CacheOption = BitmapCacheOption.OnLoad;
img.UriSource = new Uri(@"d:/a.jpg");
img.EndInit();
this.xImage.Source = img;

sw.Stop();
System.Diagnostics.Debug.WriteLine("Test2 : " + sw.Elapsed.TotalMilliseconds + " msec");
}

// Image Option 3 : 394 msec
public void Test3()
{
Stopwatch sw = new Stopwatch(); sw.Start();

BitmapImage img = new BitmapImage();
img.BeginInit();
img.CacheOption = BitmapCacheOption.OnLoad;
img.DecodePixelWidth = 300;
img.UriSource = new Uri(@"d:/a.jpg");
img.EndInit();
this.xImage.Source = img;

sw.Stop();
System.Diagnostics.Debug.WriteLine("Test3 : " + sw.Elapsed.TotalMilliseconds + " msec");
}

// Image Option 4 : 0.17 msec
public void Test4()
{
Stopwatch sw = new Stopwatch(); sw.Start();

BitmapImage img = new BitmapImage();
img.BeginInit();
img.CacheOption = BitmapCacheOption.OnDemand;
img.CreateOptions = BitmapCreateOptions.DelayCreation;
img.DecodePixelWidth = 300;
img.UriSource = new Uri(@"d:/a.jpg");
img.EndInit();
this.xImage.Source = img;

sw.Stop();
System.Diagnostics.Debug.WriteLine("Test4 : " + sw.Elapsed.TotalMilliseconds + " msec");
}

// Image Option 5 : 0.18 msec
public void Test5()
{
Stopwatch sw = new Stopwatch(); sw.Start();

BitmapImage img = new BitmapImage();
img.BeginInit();
img.CacheOption = BitmapCacheOption.OnLoad;
img.CreateOptions = BitmapCreateOptions.DelayCreation;
img.DecodePixelWidth = 300;
img.UriSource = new Uri(@"d:/a.jpg");
img.EndInit();
this.xImage.Source = img;

sw.Stop();
System.Diagnostics.Debug.WriteLine("Test5 : " + sw.Elapsed.TotalMilliseconds + " msec");
}

 



해당 내용은 (주)데브존의 웹봇이 자동으로 저희 홈페이지와 API로 동기화한 내용입니다. 자세한 내용은 홈페이지 http://www.devzone.co.kr 또는 모바일 폰에서 http://devzone.co.kr을 접속 하여 확인해 보시기 비랍니다.
-  대표 전화 : 02) 2061 - 0753   - Fax : 02) 2061 - 0759   - Skype : devzone24
-  주소 : 서울특별시 양천구 목1동 923-14. 현대드림타워 1024호
-  기술 문의: 02) 2061-1259 김민석 기술이사


댓글 없음:

댓글 쓰기