1

私は iPad 用の描画アプリを作成しており、プロファイリングを行っていたので、どこで描画を高速化できるかを確認できました。

私の描画方法には、次の 4 行のコードがあります。

    CGContextDrawImage([DrawingState sharedState].context, CGRectMake(0.0f, 0.0f, [DrawingState sharedState].screenWidth, [DrawingState sharedState].screenHeight), unzoomedBufferImage);

    CGImageRef image = CGBitmapContextCreateImage([DrawingState sharedState].context);
    CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, 768, 1024), image);
    CGImageRelease(image);

最初の行は時間の 18.8% を占め、2 番目、3 番目、および 4 番目の行は時間の 4.5% しか占めておらず、CGContextDrawImage 行は 3.5% を占めています。

これら 2 つの CGContextDrawImage 関数のパフォーマンスが大きく異なるのはなぜですか (18.8% 対 3.5%)。

注: [DrawingState sharedState].screenWidth と [DrawingState sharedState].screenHeight はそれぞれ 768 と 1024 であるため、理論的には同じ量の描画を行っています。

4

1 に答える 1

6

サンプリングを使用しているため、これは時間を費やしている場所の完全に正確な図ではない可能性があります..

私はこのコードを試してみます:

DrawingState * state = [ DrawingState sharedState ] ;
CGContextRef context = state.context ;
CGRect r = { .size = { state.screenWidth, state.screenHeight } } ;

CGContextDrawImage( context, r, unzoomedBufferImage);

CGImageRef image = CGBitmapContextCreateImage( context );
CGContextDrawImage(context, r, image);
CGImageRelease(image);

より多くの情報を得るために。

つまり、物事が理にかなっていないときは、「真実であると知っている」ことについての仮定を変えてみてください

これで情報が明らかにならない場合は、私のプロファイリング マクロでコードをインストルメント化してみてください: https://gist.github.com/1905396 :)

于 2012-08-20T19:35:01.627 に答える