実際に gcc-4.1.0 で -fprofile-generate -fprofile-use を使ってみた.使用したコードは,手元にあった自作のもの.26028ステップもあります(涙
両オプションは コンパイル時とリンク時 両方で指定する必要がある.
$ export CPPFLAGS="-fprofile-genereate" $ export LDFLAGS="-fprofile-genereate" $ make clean $ make
バイナリを数回動かして,データをサンプルする.
$ export CPPFLAGS="-fprofile-use" $ export LDFLAGS="-fprofile-use" $ make clean $ make
2回目のbuildでは,以下のようなワーニングが出たりするが,
thread_core.cpp: In function '(static initializers for thread_core.cpp)': thread_core.cpp:409: note: file thread_core.gcda not found, execution counts estimated
とりあえずベンチマークの結果は以下のようになった.
適用前 | 適用後 | |
---|---|---|
ある処理の処理時間平均(msec) | 245 | 229 |
一割ほど速くなっている??