2010-06-04 4 views
0

iPhone 앱에서 스크롤 성능을 측정 할 수있는 방법이 있습니까? 초당 업데이트 수 나는 스크롤링 성능을 향상시키기 위해 다양한 기법을 시도하고 있지만 실제로 효과가 있는지를 판단하는 것이 때때로 어렵습니다.부드러운 스크롤링 성능 측정

답변

2

스크롤 위임자가있는 경우 scrollViewDidScroll: 메서드를 구현할 수 있습니다. 구체적으로 :

//header: 
@interface MyClass : NSObject <UIScrollViewDelegate> { 
    CFAbsoluteTime last; 
    int updateCount; 
    CFTimeInterval timeTotal; 
} 
@end 

//implementation: 
@implementation MyClass 

- (void)scrollViewDidScroll:(UIScrollView *)scrollView { 
    CFAbsoluteTime time = CFAbsoluteTimeGetCurrent(); 
    if (last > 0) { 
     timeTotal += time - last; 
     ++updateCount; 
     if (timeTotal > 1) { 
      NSLog(@"Updates Per Second: %.2f", updateCount/timeTotal); 
      updateCount = 0; 
      timeTotal = 0; 
     } 
    } 
    last = time; 
} 

@end 

그런 것. 테스트되지 않았으므로 로깅이 잘못되었을 수 있습니다. 하지만이를 사용하려면 대리자를 scrollview.delegate 속성에 할당하면됩니다.