1

次のような単純なCプログラムがあります

main(int argc, char *argv[])
{
    /* Calling read function to character device driver*/
    int fd = fopen("MyCharDevice",0);

    /*write call to device and further code*/
    return 0;
}

を使用してプロファイリングしてgprofいるときに、main()関数自体の時間が得られません。

$ gprof -b -a a.out > analysis.txt

char デバイスを呼び出している場所 (そのプロファイリングを行う必要があります)。デバイスドライバーの呼び出しに対応するコードを他の関数に入れてみましたが、同じ結果が得られました。

の内容は次のanalysis.txtとおりです。

Flat profile:

Each sample counts as 0.01 seconds.
 no time accumulated

  %   cumulative   self              self     total           
 time   seconds   seconds    calls  Ts/call  Ts/call  name    
  0.00      0.00     0.00        3     0.00     0.00  __gmon_start__

            Call graph


granularity: each sample hit covers 4 byte(s) no time propagated

index % time    self  children    called     name
                0.00    0.00       3/3           main [3]
[4]      0.0    0.00    0.00       3         __gmon_start__ [4]
-----------------------------------------------

Index by function name

   [4] __gmon_start__

どうすれば時間を取得できるかわかりません。

私の要件:
実際には、いくつかの Linux パフォーマンス分析ツールを使用して、セマフォと R/W セマフォのパフォーマンスを比較する必要があります。だから私は使用してgprofいます。

4

1 に答える 1