1

http://pj.freefaculty.org/blog/?p=140の最後の (3 番目の) アプローチで R スクリプトのプロファイルを作成しようとしています。私がしていること(以下で説明)は正しいのだろうか?

まず、my.cppでは、リンクに を追加するよう#include <gperftools/profiler.h>に記載されていますが、これは機能しません。ヘッダーが別のディレクトリにあることがわかりました。私にとっては#include <google/profiler.h>.

次に、プロファイリングするコードの周りに次のコードを配置します

ProfilerStart("./myprofile.log") 
//the part of the code to be profiled
ProfilerStop()

次に、以下を含むスクリプト mytest.R を作成しました。

Sys.setenv("PKG_LIBS"="-lprofiler")
sourceCpp('my.cpp') #  for compiling the cpp file
... (use some functions defined in my.cpp

最後に、bash で実行すると

$ R -f mytest.R

Rセッションを実行し、Rmytest.R内のコンテンツを実行し、出力後にRを終了します

PROFILE: interrupts/evictions/bytes = 353/0/1988

プロファイリングが正常に実行されたことを意味しますか? 「中断」と「立ち退き」は私には面倒に見えます。

へのプロファイリング出力を生成しますmyprofile.log

$ google-pprof --text /usr/bin/R myprofile.log 

私は見えます

Total: 353 samples
      37  10.5%  10.5%       37  10.5% b313b2cb
      21   5.9%  16.4%       21   5.9% b313b2b8
      18   5.1%  21.5%       18   5.1% b313b2ce
      15   4.2%  25.8%       15   4.2% _IO_str_pbackfail
      10   2.8%  28.6%       10   2.8% b69be532
       9   2.5%  31.2%        9   2.5% b69be520
       7   2.0%  33.1%        7   2.0% b69bd111
       6   1.7%  34.8%        6   1.7% b313b2dc
       6   1.7%  36.5%        6   1.7% b69bd132
       5   1.4%  38.0%        5   1.4% b69bb50f
       5   1.4%  39.4%        5   1.4% b69bb6d8
       4   1.1%  40.5%        4   1.1% b3133bda
       4   1.1%  41.6%        4   1.1% b3134c2b
       4   1.1%  42.8%        4   1.1% b313b298
       4   1.1%  43.9%        4   1.1% b69bd159
       3   0.8%  44.8%        3   0.8% b3134c32
       3   0.8%  45.6%        3   0.8% b313b29b
       3   0.8%  46.5%        3   0.8% b313b2c8
       3   0.8%  47.3%        3   0.8% b69bb6e0
       3   0.8%  48.2%        3   0.8% b69bb6f1
       3   0.8%  49.0%        3   0.8% b69bcef1
       3   0.8%  49.9%        3   0.8% b69bd100

最後の列のエントリは人間が読めるものではありません。

私は何かを見逃しているのだろうか?ありがとう!

4

1 に答える 1

1

Instead of

google-pprof --text /usr/bin/R myprofile.log

if you issue sourceCpp with verbose=T you'll see the file path and generated object file...

Building shared library
--------------------------------------------------------

DIR: /tmp/RtmpyxYB19/sourcecpp_79831e029f

/usr/lib/R/bin/R CMD SHLIB -o 'sourceCpp_2.so' --->8---

so try using (in this instance)

google-pprof --text /tmp/RtmpyxYB19/sourcecpp_79831e029f/sourceCpp_2.so myprofile.log
于 2015-12-06T23:01:37.743 に答える