Pebble Coding

ソフトウェアエンジニアによるIT技術、数学の備忘録

macOSにてrustプロジェクトのprofileを取る

### cargo-profiler
インストール
$ cargo install cargo-profiler

実行するにはbinを含むrustプロジェクトの存在するディレクトリで、
$ cargo profiler callgrind
を実行します。
ライブラリモジュールの場合のやり方が分かっていません。

参考:
cargo-profilerを試す | κeenのHappy Hacκing Blog


### cargo-instruments
インストール
$ cargo install cargo-instruments

実行
ここではライブラリモジュール内のexample/hellp_worldのプロファイルを取ってみます。

$ cargo instruments --example hello_world
   Compiling ellipticcurve v0.1.0 (/Users/pebble8888/develop/ellipticcurve)
    Finished dev [unoptimized + debuginfo] target(s) in 0.41s
   Profiling target/debug/examples/hello_world
 Wrote Trace target/instruments/hello_world_2019-11-26T23:33:53.trace

吐き出されたトレースファイルをダブルクリックするとXcodeをイントールしてあれば、Instrumentで開いてくれます。
これはパネエ。。

f:id:pebble8888:20191126234033p:plain:w600


参考:
https://crates.io/crates/cargo-instruments